You are on page 1of 5

PROGRAM 1: A simple quiz game program that asks a user a

question and he has 3 chances to guess the answer.

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.

1. Declare the variables meter and kilometer as double.


2. Display the prompt “Enter the value in meters: ”
3. Read the input value from the user and store it in the variable meter.
4. Calculate the value in kilometer by dividing meter by 1000 and store the result
in the variable kilometer.
5. Display the message “The value in kilometer is: ” followed by the value of
kilometer.
6. End of program.
PROGRAM 4: A program that asks for age and height, and
checks if the users is qualified for basketball tryout.

1. Declare the variables age as an integer and height as a double.


2. Display the prompt “Enter your age: ”
3. Read the input value from the user and store it in the variable age.
4. Display the prompt “Enter your height: ”
5. Read the input value from the user and store it in the variable height.
6. If age is greater than or equal to 18, then:
a. If height is greater than or equal to 167, then:
 Display “You are qualified for tryouts!”
b. Else:
 Display “You di not meet the height requirements”
7. Else:

 Display “I’m sorry! You are not qualified for tryouts ☹”


8. End program.
PROGRAM 5: A program that outputs a sign that forms a
right triangle and asks a size of the shape from user.

1. Declare the variable num as an integer.


2. Display the prompt “Enter a number: ”
3. Read the input value from the user and store it in the variable num.
4. Start a loop from row = 1 to row <= num:
a. Start a nested loop from col = 1 to col <= row:
 Display “+ ”
b. After the inner loop finishes, display a newline character to move to the
next row.
5. End program.

You might also like