Saturday, 17 November 2018

LAB ACTIVITY 6 : Control Structure

Exercise :

a) Write a program using if … else statement to display student’s bachelor class of graduation based on Cumulative Grade Point Average (CGPA) by referring to the table below.





b) Write an interactive program that contains if … else statement to calculate the area of a rectangle OR triangle OR circle. The selection depends on the character entered by the user -R/r for rectangle and T/t for triangle and C/c for circle. You may use the following equation:

area of rectangle = width × length

area of triangle = 12× base × height

area of circle = 3.142 × radius2





c) Modify the program in (b) by using switch … case statement. 

 




No comments:

Post a Comment