please help! I\'m in intro to c++ programming and do not understand this problem
ID: 3799847 • Letter: P
Question
please help! I'm in intro to c++ programming and do not understand this problem. does not need to be intricate, as this is an introduction course..please help.thanks
Explanation / Answer
Below is the c++ program which needs two variable, employees total hours worked and rate per hour. You can save this file in Cpp8/Chap07 folder in a new project Introductory18.
#include <iostream>
using namespace std;
int main()
{
float tothours, hourrate, totearning;
//Enter the variables needed i.e., number of hours and hourly rate of employee
cout << "Enter the numbers of hours the employee worked and the employee's hourly rate ";
cin >> tothours >> hourrate;
// If number of hours is greater than 40
if(tothours > 40)
{
// total earning will be full price up to 40 hours and half price after 40 hours
totearning = (40 * hourrate) + ( (tothours - 40 ) * (hourrate/2) );
}
else
{
//if total hours less than 40 hours, full price paid
totearning = tothours * hourrate;
}
//print the total earning
cout <<"Total earning is = " << totearning << endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.