
Mohammad Ali Jinnah University, Islamabad Campus
Computer Programming (Lab) (CS1121)
Exercise 4
Read and analyse the following problem statements, extract information for designing
the solution. Explain your proposed solution step by step(use comment). All questions
must be solved in only one (.cpp) file (use menu)
1. A student's Grade Point Average (GPA) is computed by multiplying the number of
credit hours of each course by the grade
points assigned to grade earned, then
dividing the sum of these products by the
total number of credit hours in which the
student was registered where as Cumulative
Grade Point Average (CGPA) is calculated
by summing all the earned grade points
divided by the total number of registered
credit hours. You are provided with the
grade points, your task is to write a program
that calculates students GPA and CGPA by taking as many grades as input as the
number of courses registered in current semester.
i. By using If-else statements.
ii. By using Switch cases.
2. Write a program that asks a number from the user and print that many stars in a line.
(print five lines)
3. Write a program that prompts the user for the current year, the user's current age, and
another year. It then calculates the age that the user was or will be in the second year
entered.
4. Alter Q.3 so that if "another_age" works out to be more than 150, the screen output is:
Sorry, but you'll probably be dead by [year]!
5. Write a program for converting number of hours to seconds.
6. A shopkeeper announces a package for customers that he will give 10 % discount on
all bills and if a bill amount is greater than 5000 then a discount of 15 %. Write a C++
program which takes amount of the bill from user and calculates the payable amount
by applying the above discount criteria and display it on the screen.
7. Write a program which asks user to withdraw money from his ATM account. The
initial balance is taken as 10000. Your account can contain no less than 500, so if the
user enters amount that exceeds this limit, you would tell him that you cannot
withdraw. Otherwise withdraw money from his account and show the remaining
balance.