You are on page 1of 3

IF ELSE STATEMENT

Scenario 1: A restaurant wants to implement a loyalty program for its customers. The program
awards points to customers for each purchase they make, and the points can be redeemed for
discounts on future purchases.
Problem: Write a C++ program that prompts the user to enter the amount of their purchase and
calculates the number of loyalty points they will receive. If the purchase amount is equal to and
less than P1000.00, the program will award 1 point for every peso spent. If the purchase amount
is more than P1000.00, the program will award 2 points for every peso spent.

Scenario 2: You are designing a program to calculate the grade for a student based on their
score in a test. The program should take the student's score as input and output their grade
according to the following grading system:
A grade: 90-100
B grade: 80-89
C grade: 70-79
D grade: 60-69
F grade: 0-59
Problem: Write a C++ program that prompts the user to enter their score and calculates their
grade using an if statement. If the user enters an invalid score (less than 0 or greater than 100),
the program should output an error message. Finally, the program should output the student's
grade.

Scenario 3: You are writing a program for a retail store that sells shirts. The individual cost of shirt
is worth P250.00. The store offers a discount based on the quantity of shirts purchased. The
discount is applied as follows:

• If the customer purchases 1-4 shirts, there is no discount.


• If the customer purchases 5-9 shirts, there is a 10% discount.
• If the customer purchases 10 or more shirts, there is a 20% discount.
Problem: Your task is to write a C++ program that prompts the user to enter the quantity of shirts
purchased, and then calculates and displays the total amount to pay and the discount amount
(if any) based on the above rules.
SWITCH CASE STATEMENT

Scenario 1: You are designing a program that helps a user to choose a color for a t-shirt design.
The program should present the user with a list of color options and allow them to select a color
by entering a corresponding number. After the user selects a color, the program should output a
message confirming their selection and display the color name.
Problem 1: Write a C++ program that displays a list of color options to the user and uses a switch
statement to process their color selection. The program should prompt the user to enter a
number to select a color from the following options:
1. Red
2. Blue
3. Green
4. Yellow
5. Black
If the user enters a number that is not in the list, the program should output an error message.
After the user selects a color, the program should output a message confirming their selection
and display the name of the color they chose.

Scenario 2: You are designing a program for a restaurant that allows customers to place orders
for food items from a menu. The menu contains a variety of items, including burgers,
sandwiches, salads, and drinks. The program should take the customer's order and the quantity
as input and output the total price of their order.
Problem 2: Write a C++ program that prompts the user to select items from a menu using a
switch statement. The program should display the following menu to the user:
1. Burger – P50.00
2. Sandwich – P45.00
3. Salad – P35.00
4. Drink – P25.00
The program should prompt the user to select an item by entering its corresponding number.
Once the user has made their selections, the program should calculate the total price of their
order and output it to the user.
Note: The program should handle invalid menu selections by displaying an error message and
asking the user to enter a valid selection.
Scenario 3: You are designing a program to calculate the total cost of a customer's order at a
coffee shop. The program should prompt the user to enter the size of their coffee and the number
of add-ons they want. The sizes of coffee available are small, medium, and large. The add-ons
available are sugar, milk, and cream. Each size of coffee has a different base price, and each add-
on has a different cost. The program should use a switch statement to calculate the total cost of
the order.
Small coffee: $2.50
Medium coffee: $3.50
Large coffee: $4.50
Sugar: $0.50
Milk: $0.75
Cream: $1.00
Problem 3: Write a C++ program that prompts the user to enter the size of their coffee and the
number of add-ons they want. The program should use a switch statement to calculate the total
cost of the order and output the total cost. If the user enters an invalid size or add-on, the
program should output an error message.

You might also like