hello, i am stuck on a problem. we have a homework problem where we have to use if and else statements. i somewhat under stand them when we did simply payroll programs but now we have a bigger problem and i am getting extremely lost. here is the problem.
"There are three job classifications in a tire manufacturing company. There are hourly employees, piece count employees, and sales employees. All these employees are paid based on each employee’s hourly pay rate. They are paid straight time for the first forty hours worked. Between forty and sixty hours worked, each employee is paid time-and-a-half. Double time is paid for all hours worked over sixty.
In addition to their hourly pay, piece count workers and sales employees are paid an additional amount. The additional amount paid to piece count workers is based on the number of tires produced by them. (The number of tires produced is referred to as the “piece count”.) The additional amount paid to sales employees is based on the dollar amount of sales made."
here is my code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int main () {
char etype;
string ename;
float hoursworked,grosspay,payrate,Ppay,comm,netsales,sales,pcount;
cout << "Enter an employee name: ";
getline(cin,ename);
cout << "\nEnter the employee type. ";
cout <<"\nH\tEnter if hourly employee. ";
cout <<"\nP\tEnter is hourly plus piece credit.";
cout <<"\nS\tEnter if sales plus commission";
cout <<"\nEnter your response here: ";
cin >> etype;
if(toupper(etype)!='H' || toupper(etype)!='P' || toupper(etype) !='S')
{
if(toupper(etype)=='H')
{
cout <<"\nEnter the hours worked: ";
cin >> hoursworked;
cout << "\nEnter the pay rate: ";
cin >> payrate;
if(hoursworked <= 40)
grosspay= hoursworked * payrate;
else
if(hoursworked <= 60)
grosspay= 40*payrate+1.5*payrate *(hoursworked-40);
else
grosspay= 70 *payrate+2*payrate*(hoursworked-60);
}
return 0;
}
| |
here are some things i dont understand (it isnt done)
i have a menu in my program.what do i need to do so that my output is different based on the variable my user enters? i.e if i enter "a" then the user will get a different set of results then if i had entered "b"
i am getting lost in if and else statements. i dont know exactly why i am using if else.