the code compiles but when i try running the .exe it closes. It looks liek for the 2 seconds its up it works, but then it closes itself. What am i doing wrong? heres the code:
#include <iostream>
using namespace std;
int main()
{
// sets variables to be set in the program later on
double hours_worked, hourly_pay, gross_pay, ss_wh, wh_tax, net_pay, gross_pay_total, ss_wh_total, wh_tax_total, net_pay_total, checks;
cout << "\nInput hours worked(0 to quit):";
cin >> hours_worked;
// Loop to calculate all info
while (hours_worked > 0)
{
// Inputs hourly rate per hour
cout << "\nInput pay rate per an hour :";
cin >> hourly_pay;
if (hours_worked > 40)
gross_pay = (hours_worked * hourly_pay) + (hours_worked - 40) * (hourly_pay * 1.5);
if (hours_worked = 0)
cout << "\nTOTALS\n";
cout << "Total Payroll: " << gross_pay_total;
cout << "\nNumber of Check: " << checks;
cout << "\nAverage Paycheck: " << net_pay_total;
cout << "\n\nTotal SS Withheld:" << ss_wh_total;
cout << "\nTotal Witholding: " << wh_tax_total;
// Does all calc for taxes and net worth
if (hours_worked < 40, hours_worked > 0)
gross_pay = hours_worked * hourly_pay;
ss_wh = gross_pay * .08;
wh_tax = gross_pay * .10;
net_pay = gross_pay - ss_wh - wh_tax;
// counters
checks++;
gross_pay_total = gross_pay_total + gross_pay;
ss_wh_total = ss_wh_total + wh_tax;
wh_tax_total = wh_tax_total + wh_tax;
net_pay_total = net_pay_total + net_pay;
// Prints summary info
cout << "\nGross pay :" << gross_pay;
cout << "\nSS Witheld :" << ss_wh;
cout << "\nWitholding tax :" << wh_tax;
cout << "\nNet Pay :" << net_pay;
}
return 0;
}
I just read the info about students posting requests for answers to their HW questions. This IS a homework problem, but i have legit. tried it and just CANNOT for the life of me figure out where a mistake is. Also for some reason when it didnt end before displaying the answer, it wouldnt accept a 0 to quit the program, im not sure how to add that, any ideas? Cause the while is there, then the 2 if's for the pay differences for overtime etc, any ideas would be truely awesome. thanks!