Nested + Elseif
Nested + Elseif
Nested + Elseif
1. The Body Mass Index (BMI) is calculated as weight / (height * height) (weight in kg, height in
meters). Write a C++ program that takes weight and height as input from the user and calculate the
BMI to display the BMI category.
The BMI categories are:
BMI ≥ 30 → Obese
2. Write a C++ program that takes the person's age as input and determine the ticket price. A cinema
charges ticket prices based on age:
1 → Sunday
2 → Monday
3 → Tuesday
4 → Wednesday
5 → Thursday
6 → Friday
7 → Saturday
Nested-if Questions:
1. Write a C++ program to determine the largest of three numbers
2. Write a program to classify a triangle based on its angles:
Acute Triangle: All angles are < 90°.
3. Write a C++ program using nested-if to display the grade. If marks are invalid, display "Invalid
marks." A student is graded based on their marks, but the grade is only displayed if marks are valid
(between 0 and 100):
Marks ≥ 90 → Grade: A
Marks ≥ 80 → Grade: B
Marks ≥ 70 → Grade: C
Marks ≥ 60 → Grade: D
4. Write a C++ program to determine if the person can donate blood. To donate blood, a person must
satisfy the following conditions:
Zero
You're developing a program for a mobile phone store that offers discounts based on the
model and brand of the phone selected by the customer. Consider the following scenario:
a) The store offers two brands: "Samsung" and "Apple".
b) Each brand has one model: “Budget".
c) If the customer selects a "Budget" model, they receive a 10% discount.
You're developing a program for a coffee shop that offers discounts based on the size of the
coffee selected by the customer. Consider the following scenario:
a) The coffee shop offers two sizes: "Small" and "Large".
b) If the customer selects a "Large" coffee, they receive a 20% discount.
Write a program to calculate the electricity bill based on units consumed:
If the withdrawal amount is divisible by 100, check if the account balance is sufficient.
However, if the year is divisible by 100, it must also be divisible by 400 to be a leap year.