Sei sulla pagina 1di 1

LAB SESSION 3 Question 1 Write a program that should ask a user for a single letter which is the first

letter of a day. The program should then display the day that begin with that letter. You should use a switch statement for this. The program should not care whether you use upper or lower case, for example, pressing either S or s should result in the program displaying Saturday and Sunday. Hint: You could use multiple case clauses to handle the upper and lower case letters. For example: case f: case F: ... break;

Question 2 SSIL Limited is having a sale on all of its merchandise. The Store manager asks you to create a program that requires the clerk to enter the original price of a book and the discount rate. The program should then display both the sales discount and the new sales price. However, the clerk can only enter the discount rate if the book price is less than RM290.90 . Please write a full C++ program.

Question 3 Write a complete C++ program that takes one integer number called Num and displays the value of its smallest positive integer n for which 1+2+3+4.+n is at least equal or closest to the integer number Num. For example; if the Num is 10, the n number should be 4 because 1+2+3+4 =< 10 if the Num is 21, the n number should be 6 because 1+2+3+4+5+6 =< 21 Example of output: Enter an integer number: 10 The n number is 4 Enter an integer number: 21 The n number is 6

Potrebbero piacerti anche