In: Computer Science
Please use C++ program.
uses a while statement to determine the gross pay for each of several employees. When someone works 41 hours or more. They get paid 1.5x more so my problem is that in my else if statement. The C++should ask repeatedly if the user wants to continue: y or n, if the user types y, then the program should ask for the hours and rate for another employee then display the grosspay. When the user type n, then the program stops.
C++ code:
#include <iostream>
using namespace std;
int main()
{
//initializing choice
char ch='y';
//initializing hour and pay
float hour,rate;
//looping as long as ch is 'y'
while(ch=='y'){
//asking for number of hours
cout<<"Enter the number of hours: ";
//accepting it
cin>>hour;
//asking for rate
cout<<"Enter the rate: ";
//accepting it
cin>>rate;
if(hour>=41)
cout<<"Gross pay: "<<hour*rate*1.5<<endl;
else
cout<<"Gross pay: "<<hour*rate<<endl;
//asking if he want to continue
cout<<"Do you want to continue (y/n): ";
//accepting it
cin>>ch;
}
return 0;
}
Screenshot:
Input and Output: