### payroll report

 ``1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465`` ``````// Includes #include "stdafx.h" #include #include using namespace std; // Main Function int main() { cout << "This will display a payroll report.\n\n"; // Loop to do everything do { int employeenum; float gross, statetax, federaltax, fica; double spay, fpay, ficapay, netpay; cout.setf(ios_base::fixed, ios_base::floatfield); cout.precision(2); spay = gross * statetax; fpay = gross * federaltax; ficapay = gross - fica; netpay = spay - fpay - fica; cout << "Enter the employee number: "; cin >> employeenum; cout << "Enter gross pay: \$"; cin >> gross; cout << "Enter state tax percent in decimal form (EX. 40% = .40): "; cin >> statetax; cout << "Enter federal tax percent in decimal form (EX. 40% = .40): "; cin >> federaltax; cout << "Enter FICA withholdings: \$"; cin >> fica; cout << "\n\n"; // What hapens went a negative number is entered while (employeenum < 0 || gross < 0 || statetax < 0 || federaltax < 0 || fica < 0) { // Makes user re-enter data because user entered a number less than 0 cout << "Re-enter data must be greter than 0: "; cin >> employeenum; cout << "\$ "; cin >> gross; cin >> statetax; cin >> federaltax; cout << "\$ "; cin >> fica; } cout << "Payroll Report:\n\n"; cout << "The Employee Number is: " << employeenum << endl; cout << "You gross pay is: \$" << gross << endl; cout << "Your state tax total is: \$" << spay << endl; cout << "Your federal tax total is: \$" << fpay << endl; cout << "Your FICA pay is: \$" << fica << endl; cout << "Your total netpay is: \$" << netpay << endl; } while (employeenum == 0); _getch(); return 0; }``````

Am i missing something or putting something somewhere where it doesnt belong.

This program is suppose to keep running until the user enters 0 as the employeenum, but when i goto compile it it says

payroll report.cpp(61): error C2065: 'employeenum' : undeclared identifier

this part is the error

 `` `` ``} while (employeenum == 0)``

any ideas why or what im doing wrong?
you encapsulated the declaration of employeenum in the scope of the do - while statement, this means that employeenum is not defined outside of the paranthesis `{ ... }`. But `while (employeenum == 0)` is not within this block of course, so employeenum is unknown.

To solve this problem you just need to move the declaration of employeenum in front of the do-while statement.
Last edited on
ok thank you
Topic archived. No new replies allowed.