Professional Documents
Culture Documents
Lab Assignment 2 - Selection Control Structure Sep2019-Jan2020
Lab Assignment 2 - Selection Control Structure Sep2019-Jan2020
INSTRUCTION: For each question, write a complete program using C++ programming
language
1. Air Pollution Index (API) is used to determine the level of air pollution. The relationship
between API and air pollution level is shown in the following table:
Write a program that accepts the API value and determines the air pollution level from the
table above.
Geometry Calculator
1. Calculate the Area of a Circle
2. Calculate the Area of a Rectangle
3. Calculate the Area of a Triangle
4. Quit
Enter your choice (1-4):
If the user enters 1, the program should ask for the radius of the circle and then display
its area. Use 3.14159 for π. If the user enters 2, the program should ask for the length
and width of the rectangle, and then display the rectangle’s area. If the user enters 3, the
program should ask for the length of the triangle’s base and its height, and then display
its area. If the user enters 4, the program should end.
Page 1|2
3. The CityPhone Telephone Company assigns you to develop a billing system based on
the tariff as follows:
Customer
Tariff Rent (RM)
Category
The first 100 units : RM0.10 per unit
Home The next 200 units : RM0.17 per unit 25.00
Over 300 units : RM0.20 per unit
The first 200 units : RM0.30 per unit
Commercial The next 400 units : RM0.27 per unit 50.00
Over 600 units : RM0.20 per unit
The first 100 units : RM0.10 per unit
Industrial 100.00
Over 100 units : RM0.20 per unit
Write a complete C++ program that prompts the user to enter the following data:
• The customer name
• The customer address
• The customer category
• The units used
Then, the program will calculate the amount due and print the bill.
Page 2|2