help with payrate

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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include<iostream>
#include<iomanip>
using namespace std;

void grosspay(double &hours, double &payrate, double &gross_pay);
double tgp(int time, double rate, double gp);
          
int main()
{
    int employees;
    int n, x, u; 
    double y = 0.00;
    double tgrosspay = 0.00;
    double tgross = 0.00;
    //uble gpay = 0.00;
    int workers;
    double amount = 0.00;
    double pay_percentage = 0.00;
    double pay_g = 0.00;
    cout << "\t\t Welcome to the Gerston Blankets payroll!";
    cout << endl << endl << endl;
    
    cout << "Press -1 to end. ";
    cin >> u;
    cout << endl << endl;
    
    
    cout << "Enter the number of employees: ";
     cin >> employees;
     cout << endl << endl;
     for(x=0; x<=employees-1; x++)
     {
    grosspay(amount, pay_percentage, pay_g);
    tgrosspay = tgp(amount, pay_percentage, pay_g);
    
    y = y + tgrosspay;
    }
    cout << fixed << setprecision(2);
    cout << "Total gross pay is: $" << y; 
    cout << endl;
    
    
    if(u == -1)
    {
         cout << "This program will end." << endl << endl;
    }
    system("pause");
}
void grosspay(double &hours, double &payrate, double &gross_pay)
{
     //double gross_pay;
     //int x;
     //double hours;
     //double payrate;
     //double payra = 15.00;
     //int employees;
     char dollar='$';
     double excess;
     int min = 40;
     
          cout << endl << "Enter hours worked for employee: ";
          cin >> hours;
          cout << "Enter pay rate for employee: " << "$";
          cin >> payrate;
          
          if(hours > 40)
          {
               excess = hours - min;
               //payrate = excess * (payrate/2 + payrate);
               gross_pay = payrate * hours * (excess *(payrate/2 + payrate));
          }
          
          else
          {
              gross_pay = payrate * hours;
          }
          cout << fixed << setprecision(2);
          cout << "Gross pay for employee is: " << "$" << gross_pay;
          
           
          cout << endl;
                         
       
}
double tgp(int time, double rate, double gp)
{
     double total_grosspay = 0.00;
     //double gross_pay;
     //int x, workers;
     double overtime = 15.00;
     if(time > 40)
          {
               rate = rate + (overtime/2);
          }
          
          gp = rate * time;
     
         total_grosspay = total_grosspay + gp;
     
     
     //cout << total_grosspay << endl;
     return total_grosspay;;
}





total grosspay is wrong

- If total grosspay is wrong, then you're keeping the running total incorrectly, or doing something else incorrectly.
Topic archived. No new replies allowed.