net pay average output window disappearing
Jan 3, 2014 at 12:41am UTC
I am trying to write a code for netpay average and the code seems to work, but the output screen. will disappear as soon as I use the deg option and/or the ctrl and F5 (no debug). How do I fix this?
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
# include <iostream>
# include <fstream>
# include <string>
# include <iomanip>
using namespace std;
int main() {
int EmployeeId[100], i = 0, n = 0;
double TaxAmount[100], HourlyRate[100], GrossPay[100], NetPay[100], HoursWorked[100], RegularHours[100];
double TaxRate[100], RegularPay[100], OvertimePay[100], OverTimeHours[100];
char MaritalStatus[100][1];
string SSnumber[100], FirstName[100], LastName[100];
ifstream fin("employee.txt" );
std::cout << " WINCHESTER FIREARMS PAYROLL" << endl << endl;
std::cout << " ID First Last SSnumber Hrs RHrs OtHrs HRate MStatus" << endl;
cout << "------------------------------------------------------------------" << endl;
while (fin >> EmployeeId[n] >> FirstName[n] >> LastName[n] >> SSnumber[n] >> HoursWorked[n] >> HourlyRate[n] >> MaritalStatus[n])
{
n++;
}
fin.close();
while (i<n)
{
if (HoursWorked[i] > 40)
{
OverTimeHours[i] = HoursWorked[i] - 40;
RegularHours[i] = 40;
}
else
{
OverTimeHours[i] = 0;
RegularHours[i] = HoursWorked[i];
}
std::cout << EmployeeId[i] << " " << std::left << setw(8) << FirstName[i] << std::left << setw(9) << LastName[i]
<< setw(15) << SSnumber[i] << setw(5) << HoursWorked[i] << setw(6) << RegularHours[i] << setw(6) << OverTimeHours[i] << setw(7) << HourlyRate[i]
<< setw(1) << MaritalStatus[i] << " " << endl;
i++;
}
return 0;
}
//payroll array separate loops 1/2/13 Alust
Jan 3, 2014 at 2:31am UTC
Use cin.get() ; to wait for a newline character but you may want to clear the buffer with cin.ignore(); before.
Aceix.
Topic archived. No new replies allowed.