### help with payrate

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103`` ``````#include #include 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.