You are on page 1of 6

EXERCISE SELECTION 1.

Write an if statement to display a message that indicates the education level of a student based on his/her number of years of schooling :

If they enter an invalid number, your program should be able to display a message to indicate bad data as well. 2. A bank in your town updates its customers accounts at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance of RM300. If a customers balance falls below that minimum balance, there is a service charge of RM10.00 for saving accounts and RM25.00 for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows :1. saving accounts receive 4% interest 2. checking accounts with balance of up to RM5000 more than the minimum balance receive 3% interest; otherwise, the interest is 5%. Write a program that reads a customers account number, account type (S or s for Saving, C or c for checking account), and the current balance. The program should then output the account number, account type, the current balance and the new balance after the service charge or interest. 3. Cempaka Hospital needs a program to compute and print a billing statement for each patient. Charges for each day are as follows :a) Room charge depending on the room type. Room Type Charge per day Private Room (P) Semi-private Room (S) RM 125 RM 95

Ward

(W)

RM 75

b) c)

Telephone charge if the patient uses this facility is RM1.75 per day. Television charge if the patient requests this facility in his/her room is RM3.50 per day. Get the data from the user, compute the patients bill and print an appropriate billing statement. Sample input is : 5 number more than 0) P enters Uppercase) N facility (Y, y, N or n) Y or n) An output for the sample input given :CEMPAKA HOSPITAL PATIENT BILLING STATEMENT Number of Days in Hospital : 5 days Room Charge : RM 625.00 Telephone Charge : RM 0.00 Television Charge : RM 17.50 TOTAL DUE : RM 642.50 4. A three minutes telephone call to Kuala Terengganu costs RM1.15. Each additional minute costs 26 cents. Given the total length of a call in minute and print the cost. Sample Input Data 2 8 13 Sample Output displayed RM 1.15 RM 2.45 RM 3.75 Type of Room : P which means uses the television facility (Y, y, N which means does not use the telephone which means 5 days (assume user enters which means Private room type (assume user

5. At UiTMCK, students have to pay RM150 per credit hour taken for each semester. A student must take at least 12 credit hours to be considered as full time and no students may take more than 21 credit hours. Write a C++ program that input the students credit hours taken for the semester and then output the student status whether full or part time student and the payment made by the student for the semester. Make sure to display an error message if the credit hours entered is negative or more than 21. 6. Write a C++ program that will accept two numbers that are greater than zero and an arithmetic operator (+, - , *, /) from the user. The program will then perform calculation on those numbers using the operator and display the result of that operation. Sample Input Sample Output Data displayed 8 5 4 + 2 * 12 10 16

24 8 -

7. ABC Services Sdn. Bhd. imports two types of car namely COMPACT and SEDAN. Each type has several packages and prices as illustrated in the following table: The company has to pay 200% tax for each car. Type COMPACT Package Standard Limited Edition SEDAN Standard Sporty Limited Edition Buying Price RM24,000 RM28,000 RM35,000 RM37,000 RM41,000

Write a C++ program to accept the type and package of car, and then calculate and display the cost of car (new price after taxed). You can use your own single character code to represent the type and package of car. 8. Assume that a price of a concert tickect depends on the seat location, as shown in the following table. The user can enter the seat location in any case:-lower or upper case letter.

Seat Location B P L

Concert ticket price 75.00 30.00 21.00

Any other seat location should result in an incorrect seat location message. Write a program to prompt a cashier to enter the seat location & number of ticket purchased for the concert. Then the program will calculate the ticket price based on the seat location chosen & display the total amount to be paid for the concert ticket. 9. Your company offers a programming seminar to other companies to attend. The price per person depends on the number of people the company registers, as shown in the following table. (For example, if the company registers 7 people, then the total charge will be $560). Write a program that will prompt the user to enter the number of people registered and then calculate the total amount charged for that company. Number of person registered 14 5 10 11 or more Charge per person $100 $ 80 $ 60

10. Using SELECTION statement, write a complete program to calculate the area of shapes mentioned in the above table. Declare as constant to the value of 3.142.
Menu Option Diagram Formula

Area of triangle = * b * h

Area of rectangle = b * h

Area of ellipse = * a * b

Area of square = a2

Area of trapezoid = * (a+b) * h

11.

Write a complete program to determine discount that should be

given based on the item ordered by customer. Discount will be given according to item code and total items ordered by customer. It then calculates the ordered cost made by the customer. Item code and prices are as below:

Item code 1 2 3

Item price (per unit) RM 100.00 RM 200.00 RM 300.00

If the customer choose item 1, 20% discount will be given for total items that are more or equal to 10. Total items that are lesser than 10 will be given 10% discount. If the customer chose item 2, 25% discount will be given for total items that are more or equal to 5. Total items that are lesser than 5 will be given 15% discount. Meanwhile, If the customer choose item 3, 10% discount will be given for total items that are more or equal to 3. Total items that are lesser than 3 will not be given any discount.

You might also like