c# - How do I add a loop to my code so the code keeps going until the user types '!'? -
i have no idea doing hard enough am. feel free correct code, me add loop or start on scratch.
here's problem trying make console based application asks user type lowercase letter keyboard. if character entered lowercase letter, display “ok”; if not lowercase letter, display error message. program should continue until user types ‘!’.
here's have far:
if (char.islower(c)) { console.writeline("ok"); } else if (char.isupper(c)) { console.writeline("the character not lowercase letter."); } else if (char.isdigit(c)) { console.writeline("the character not lowercase letter."); } else { console.writeline("the character not lowercase letter."); } console.readkey();
this code should work. loop until user enters exclamation point.
while (true) { var inputcharacter = console.readkey().keychar; if (inputcharacter == '!') { break; } if (char.islower(inputcharacter)) { console.writeline("ok"); } else { console.writeline("the character not lowercase letter."); } }
Comments
Post a Comment