Managed to find how to have the numbered lines, but I am still confused as to why there are build errors on those lines.
This is the build errors now:
"1>------ Build started: Project: IC09_PayrollReport, Configuration: Debug Win32 ------
1> Source.cpp
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(15): error C4700: uninitialized local variable 'employeeNum' used
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(26): error C4700: uninitialized local variable 'grossPay' used
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(36): error C4700: uninitialized local variable 'totalGross' used
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(37): error C4700: uninitialized local variable 'stateTax' used
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(47): error C4700: uninitialized local variable 'totalState' used
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(48): error C4700: uninitialized local variable 'federalTax' used
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(58): error C4700: uninitialized local variable 'totalFederal' used
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(59): error C4700: uninitialized local variable 'fICA' used
1>c:\users\randy\desktop\ic09_payrollreport\ic09_payrollreport\source.cpp(68): error C4700: uninitialized local variable 'totalFICA' used
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========="
And then the 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 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
|
/*
Nguyen, Randy
March 7, 2016
IC09_PayrollReport
*/
# include <iostream>
# include <iomanip>
# include <climits>
using namespace std;
int main() {
int employeeNum, grossPay, stateTax, federalTax, fICA,
totalGross, totalState, totalFederal, totalFICA, totalNet;
do {
if (employeeNum <= 0 || cin.fail()) {
cout << "Please enter the employee number (enter 0 to quit): ";
cin >> employeeNum;
cout << "Error: employee number must be a number greater than or equal to 0." << endl;
cin.clear();
cin.ignore(INT_MAX, '\n');
}
else {
cout << "Please enter the employee number (enter 0 to quit): ";
cin >> employeeNum;
if (grossPay < 0 || cin.fail()) {
cout << "Please enter gross pay: $";
cin >> grossPay;
cout << "Error: gross pay must be a number greater than or equal to 0." << endl;
cin.clear();
cin.ignore(INT_MAX, '\n');
}
else {
cout << "Please enter gross pay: $";
cin >> grossPay;
totalGross = totalGross + grossPay;
if (stateTax < 0 || cin.fail()) {
cout << "Please enter state tax: $";
cin >> stateTax;
cout << "Error: state tax must be a number greater than or equal to 0." << endl;
cin.clear();
cin.ignore(INT_MAX, '\n');
}
else {
cout << "Please enter state tax: $";
cin >> stateTax;
totalState = totalState + stateTax;
if (federalTax < 0 || cin.fail()) {
cout << "Please enter federal tax: $";
cin >> federalTax;
cout << "Error: federal tax must be a number greater than or equal to 0." << endl;
cin.clear();
cin.ignore(INT_MAX, '\n');
}
else {
cout << "Please enter federal tax: $";
cin >> federalTax;
totalFederal = totalFederal + federalTax;
if (fICA < 0 || cin.fail()) {
cout << "Please enter FICA withholdings: $";
cin >> fICA;
cin.clear();
cin.ignore(INT_MAX, '\n');
}
else {
cout << "Please enter FICA withholdings: $";
cin >> fICA;
totalFICA = totalFICA + fICA;
cout << "\n";
}
}
}
}
}
} while (employeeNum != 0);
totalNet = totalGross - (totalState + totalFederal + totalFICA);
cout << "Total gross pay: $" << setprecision(2) << fixed << totalGross
<< "\nTotal state tax: $" << totalState << "\nTotal federal tax: $"
<< totalFederal << "\nTotal FICA withholdings: $" << totalFICA
<< "\n\nTotal net pay: $" << totalNet << endl;
system("pause");
return 0;
}
|