You are on page 1of 2

CSEB113

COLLEGE OF COMPUTER SCIENCE AND INFORMATION TECHNOLOGY


Structured Programming - Selection
LAB OBJECTIVES:
By the end of this lab session, you should be able to:
1. Apply input validation to the program
2. Solve and write C programs using selection.
Exercises (Please do ALL):
1. Write a program that reads a positive single-digit integer number (1-7), and prints the day
equivalent to it. For example, if the user enters 5, the program should print Day 5 is FRIDAY
to the screen. You may assume that a week starts on Monday and ends on Sunday. Sample
output is as follows:
Enter a number (1 7): 5
Day 5 is FRIDAY

2. Write a program that reads your overall lab mark from the keyboard (with an assumption that
youll enter only valid value). The maximum value for lab mark is 100 and your program
needs to convert the mark to be over 15 percent. For example, if your lab mark is 90 then the
converted lab score is 13.5. Next, print My lab score is followed by the lab score. If the lab
mark percentage is more than 13, display Well done! message on the screen. Otherwise,
print Dont be sad, do your best in your final exam. message.
Two samples input and output of the program are shown below and should guide you in
writing the program:

3.

Write a program that prompts the users to enter the value of Ritcher scale number (n), and
print its equivalent effect to the users based on the following table:

CSEB113

Ritcher scale number (n)


n < 5.0
5.0 <= n < 5.5
5.5 <= n < 6.5
6.5 <= n < 7.5
n >= 7.5

Effect
Little or no damage
Some damage
Serious damage: walls may crack or fall
Disaster: house or building may collapse
Catastrophe: most buildings destroyed

4. Suppose a company decides to raise the salaries of its employees according to the following
table:
employee_status

years_of_service

percent_raise

Full-time
Full-time
Part-time
Part-time

Less than 5 years


5 years or more
Less than 5 years
5 years or more

4.0
5.0
2.5
3.0

If employee_status value is F, the employee is Full-time; if it is P, he or she is part-time.


Write a nested IF statement that computes the new salary of an employee given his or her
employee_status, years_of_service and salary by the users. (Hint: use nested
if..else)

5.

Rewrite the program in Q1 using switch statement.

You might also like