You are on page 1of 3

CS100 Computational Problem Solving

Fall 2021-2022
Muhammad Farrukh

Section 2 Friday 8 Oct

Lab# 05: Exercise

Lab Guidelines

1. You are allowed to perform/submit the lab only during the lab timings
2. Make sure you do not leave the lab without submitting your work on LMS
3. Copying/sharing code is strictly prohibited. Using any unfair means will lead to immediate
disqualification
4. Put all cpp files into a folder YourRollNo_Lab4_TAname and submit it on LMS
(Assignments>Lab4)
5. Lab ends at 8:50 pm and the submission tab closes at the same time

Task1 Total
20

Task2 Total
30

Task3 Total
30

Total Marks: 100 (80 + 20 for Viva)


Task 1 – Age checker [20 marks]

Write a program that asks the age of a person and categorizes him/her according to the
following:
Children: Less than 13
Teens: Less than 20 and more than 12
Adults: Less than 51 more than 19
Seniors: More than 50

Sample Output:

Enter the age of the person:23


Adults

Enter the age of the person:18


Teens

Enter the age of the person:55


Senior

__________________________________________________________________

Task 2 – Pythagorean checker [30 marks]

Write a program that asks the user to enter lengths of the three sides of a triangle in
any order and then prints Pythagorean if the three sides form a right triangle and print
Not Pythagorean otherwise. For the sake of simplicity, assume that the user will enter
integer lengths.

Restrictions:
You are not allowed to use logical operators(&&, ||)

Sample Output:

Enter the length of the First side of triangle:5


Enter the length of the Second side of triangle:4
Enter the length of the Third side of triangle:3
Pythagorean

Enter the length of the First side of triangle:2


Enter the length of the Second side of triangle:1
Enter the length of the Third side of triangle:1
Not Pythagorean

_____________________________________________________________

Task 3 – Electricity bill calculator[30 marks]

Write a program that asks the user to input the total number of electricity units
consumed and calculates the total electricity bill according to the given conditions:
For the first 50 units Rs. 0.50/unit
For the next 100 units Rs. 0.75/unit
For the next 100 units Rs. 1.20/unit
For units above 250 Rs. 1.50/unit

Also, an additional surcharge of 20% will be added if the total amount is greater than
Rs.500/-.

Sample Output:

Enter the number of units consumed:940


total Electricity bill after adding surcharge is:1506

Enter the number of units consumed:200


total Electricity bill is:160

You might also like