Computer Science Canada Pseudocode problem |
Author: | NEOS [ Sun Dec 07, 2008 5:48 pm ] | ||
Post subject: | Pseudocode problem | ||
This is my code and I just need to know if that's how I make it ask for the password 5 times, using the for loop. % Write a pseudocode for a program that checks to see if a password is valid. % The criteria for the password are listed below. The user must enter in the % password and a message must be given if the password is valid or invalid. % If it is invalid the program must allow the user to enter in a new one; % and again, up to 5 times.
That's my code and I just need to know if that's how I make it ask for the password 5 times, using the for loop. |
Author: | syntax_error [ Sun Dec 07, 2008 7:23 pm ] |
Post subject: | RE:Pseudocode problem |
var count. |
Author: | Insectoid [ Sun Dec 07, 2008 7:23 pm ] | ||
Post subject: | RE:Pseudocode problem | ||
You don't need to check the ascii values, you can do
|
Author: | NEOS [ Sun Dec 07, 2008 8:06 pm ] |
Post subject: | Re: Pseudocode problem |
but if I don't check the acsii code then how will the computer know what's greater than A and less than Z? |
Author: | Tony [ Sun Dec 07, 2008 8:34 pm ] | ||||
Post subject: | RE:Pseudocode problem | ||||
because otherwise you are applying the same function to both sides of the equation
is the same as
Though ultimately you are still checking if a character is in a certain numeric range, even if you don't explicitly specify the conversion. |
Author: | Insectoid [ Sun Dec 07, 2008 9:20 pm ] |
Post subject: | RE:Pseudocode problem |
Yeah, it does the same thing. It just reads better and requires less typing. |
Author: | DanielG [ Sun Dec 07, 2008 9:49 pm ] |
Post subject: | RE:Pseudocode problem |
Turing basically does the ascii conversion for you when comparing them. |
Author: | andrew. [ Mon Dec 08, 2008 4:25 pm ] |
Post subject: | RE:Pseudocode problem |
It would be something like this: Constant: password - The real password (string) Variables: passattempt - The password the user enters (string) counter - A counter to check how many times you entered in a password (integer) Main loop: Clear screen Print "Enter the password" Get passattempt Check if passattempt equals the password If it does, then exit the loop If it doesn't then add one to counter and say how may login attempts you used (counter out of 5) Check if counter equals 5 If it does, then quit (not exit, terminate the program) After the loop: Whatever you want |