| | |
Syntax Error
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
I am going back through some old code I wrote last year during school to try and refresh myself for upcoming classes. This one code I went back and tried to build it and I receive this following error: error C2059: syntax error : 'return'. I am not sure why I am getting this exactly but I am almost certain it has to do with my do while loop. Any help on fixing this error will be appreciated.
Note: I tried to make sure all my braces lined up and for each open there was a closing. I could have missed one though.
Note: I tried to make sure all my braces lined up and for each open there was a closing. I could have missed one though.
C++ Syntax (Toggle Plain Text)
HEADER.H #ifndef WORKER_H #define WORKER_H #include <cstdlib> #include <iostream> #include <iomanip> #include <string> using namespace std; const double REGWEEK = 20.0, U_RATE = 2.0, N_RATE = 1.5, T_RATE = 1.25; #endif //======================= Main.cpp #include "worker.h" int main() { // Defining variables double hours = 0.0, rate = 0.0, regpay = 0.0, othours = 0.0, otrate = 0.0, gross = 0.0, otpay = 0.0, posrate = 0.0; char position; char chioce; string emp; do{ //Collect Employee's Name cout << "Before you begin please...\n" << "Enter the employee's name: "; cin >> emp; cout << endl; // Main Menu // Display Main Menu to user with chioces and read in the users chioce cout << "Main Menu" << endl; cout << "Please enter one of the following options" << endl; cout << "U - Union\n" << "N - Non Union\n" << "T - Temporary" << endl << endl; cout << "Enter your employee's status: "; cin >> position; cout << endl; if( position == 'U' || position == 'u' ){ posrate = U_RATE; } // end of if pos == U if( position == 'N' || position == 'n' ){ posrate = N_RATE; } // end of if pos == Non if( position == 'T' || position == 't' ){ posrate = T_RATE; } // end of if pos == T // Collect Information About Employee cout << "Enter the number of hours " << emp << " worked: "; cin >> hours; cout << endl; cout << "Enter the pay rate that " << emp << " receives: "; cin >> rate; cout << endl; // Calculate Employees' Payment Amount if( hours <= REGWEEK ){ // runs code if the user has worked 20 hours or less a week gross = hours * rate; } // end of if hours <= REGWEEK else{ regpay = REGWEEK *rate; othours = hours - REGWEEK; otrate = posrate * rate; otpay = othours * otrate; gross = otpay + regpay; } // end of else hour > REGWEEK cout << emp << endl << "Gross Amount" << setw(10) << setfill('.') << "$" << gross << endl << endl; //Ask User If They Wish to Continue and Proceed Accordingly cout << "Would you like to continue to another employee?" << "\ny - yes\nn - no" << "\nEnter chioce now: "; cin >> chioce; cout << endl; while( chioce != 'n' );} return EXIT_SUCCESS; } // end of main
![]() |
Similar Threads
- syntax error? .. operator overload method problemo (C)
- syntax error that I just can't seem to find! (Visual Basic 4 / 5 / 6)
- UPDATE syntax error (MySQL)
- Subshell Problem, syntax error...Help please! (Shell Scripting)
- DECLARATION SYNTAX ERROR (for bc 31 user) (C++)
- Parse error, syntax error, Forbids declaration (C++)
Other Threads in the C++ Forum
- Previous Thread: Question about Inheritance/Classes
- Next Thread: any articles or books about pointer?
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news node output parameter pointer problem program programming project proxy python read recursion recursive reference return rpg string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





