You are an employee of a marketing organization that pays you a monthly salary of Ksh. 10,000
if you work for the recommended 160 hours a month (Monday - Friday, 9am - 5pm, for a month).
This salary can however fluctuate based on the number of hours worked, in that if you work for
more than the recommended working hours ie above 160 hours, you earn an extra 10% of your
salary but if you work for less than 160 hours, you will be deducted 10% of your salary. With the
aid of a SWITCH CASE select structure Implement a program written in C++ that would help
the finance department calculate your monthly salary based on the hours worked being the input
value of the program. [5 Marks]
#include<iostream>
using namespace std;
int main(){
cout<<"Enter the number of hours worked\n";
int hours;
cin>>hours;
switch(hours){
case 160:
cout<<"The salary is : "<<10000<<endl;
break;
case 0 ... 159:
cout<<"The salary is: "<<10000 - 0.1 * 1000<<endl;
break;
case 161 ... 400:
cout<<"The salary is: "<<10000 + 0.1 * 1000<<endl;
break;
}
}
Comments
Leave a comment