Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

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

18. Create a program that displays the weekly gross pay for any number of employees. The user will input the number of hours the employee worked and the employee's hourly rate. Employees working more than 40 hours receive time and one-half for the hours worked over 40. If necessary, create a new project named Introductory18 Project, and save it in the Cpp8WChap07 folder. Enter the C+ nstructions into a source file named Introductory18.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Save, run, and test the program.

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;
}