Professional Documents
Culture Documents
Algorithm
Algorithm
1. Set Lives = 3
2. Set correctAnswer = “VENUS”
3. Start a loop Lives > 0:
a. Display the question: “What is the hottest planet in our solar system?
(must be in CAPITAL letters):”
b. Read the user’s answer from input and store in the variable answer
c. If answer is equal to correctAnswer, then:
Display “Nicely Done!”
Break out of the loop
d. Else, the answer is incorrect:
Display “Try Again!”
Decrement Lives by 1
Display “Your lives:” followed y the current value of Lives
e. End of loop
4. If Lives equals 0, then:
Display “You lost! UwU”
5. End of program
PROGRAM 2: A while loop that outputs and indicate if the
age is legal or under age.
1. Set age = 1
2. Start a loop while age < 18:
a. Display “Under Age: ” followed by the current value of age
b. Increment age by 1
3. Display “Legal Age: ” followed by the current value of age
4. End of program
PROGRAM 3: A program that convert meters into kilometers.