Syntax Error

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2008
Posts: 21
Reputation: buddha527 is an unknown quantity at this point 
Solved Threads: 0
buddha527's Avatar
buddha527 buddha527 is offline Offline
Newbie Poster

Syntax Error

 
0
  #1
Oct 19th, 2008
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.

  1. HEADER.H
  2.  
  3. #ifndef WORKER_H
  4. #define WORKER_H
  5.  
  6.  
  7. #include <cstdlib>
  8.  
  9. #include <iostream>
  10.  
  11. #include <iomanip>
  12.  
  13. #include <string>
  14.  
  15. using namespace std;
  16.  
  17. const double REGWEEK = 20.0,
  18. U_RATE = 2.0,
  19. N_RATE = 1.5,
  20. T_RATE = 1.25;
  21.  
  22. #endif
  23.  
  24. //=======================
  25.  
  26. Main.cpp
  27.  
  28. #include "worker.h"
  29.  
  30. int main()
  31. {
  32.  
  33. // Defining variables
  34.  
  35. double hours = 0.0, rate = 0.0, regpay = 0.0, othours = 0.0,
  36. otrate = 0.0, gross = 0.0, otpay = 0.0, posrate = 0.0;
  37.  
  38. char position;
  39. char chioce;
  40. string emp;
  41.  
  42. do{
  43.  
  44. //Collect Employee's Name
  45.  
  46. cout << "Before you begin please...\n"
  47. << "Enter the employee's name: ";
  48.  
  49. cin >> emp;
  50.  
  51. cout << endl;
  52.  
  53. // Main Menu
  54. // Display Main Menu to user with chioces and read in the users chioce
  55.  
  56. cout << "Main Menu" << endl;
  57. cout << "Please enter one of the following options" << endl;
  58. cout << "U - Union\n"
  59. << "N - Non Union\n"
  60. << "T - Temporary" << endl << endl;
  61. cout << "Enter your employee's status: ";
  62.  
  63. cin >> position;
  64.  
  65. cout << endl;
  66.  
  67. if( position == 'U' || position == 'u' ){
  68.  
  69. posrate = U_RATE;
  70.  
  71. } // end of if pos == U
  72.  
  73. if( position == 'N' || position == 'n' ){
  74.  
  75. posrate = N_RATE;
  76.  
  77. } // end of if pos == Non
  78.  
  79. if( position == 'T' || position == 't' ){
  80.  
  81. posrate = T_RATE;
  82.  
  83. } // end of if pos == T
  84.  
  85.  
  86. // Collect Information About Employee
  87.  
  88. cout << "Enter the number of hours " << emp << " worked: ";
  89.  
  90. cin >> hours;
  91.  
  92. cout << endl;
  93.  
  94. cout << "Enter the pay rate that " << emp << " receives: ";
  95.  
  96. cin >> rate;
  97.  
  98. cout << endl;
  99.  
  100.  
  101. // Calculate Employees' Payment Amount
  102.  
  103. if( hours <= REGWEEK ){ // runs code if the user has worked 20 hours or less a week
  104.  
  105. gross = hours * rate;
  106.  
  107. } // end of if hours <= REGWEEK
  108. else{
  109.  
  110. regpay = REGWEEK *rate;
  111.  
  112. othours = hours - REGWEEK;
  113.  
  114. otrate = posrate * rate;
  115.  
  116. otpay = othours * otrate;
  117.  
  118. gross = otpay + regpay;
  119.  
  120.  
  121. } // end of else hour > REGWEEK
  122.  
  123. cout << emp << endl << "Gross Amount" << setw(10) << setfill('.')
  124. << "$" << gross << endl << endl;
  125.  
  126. //Ask User If They Wish to Continue and Proceed Accordingly
  127.  
  128. cout << "Would you like to continue to another employee?"
  129. << "\ny - yes\nn - no"
  130. << "\nEnter chioce now: ";
  131.  
  132. cin >> chioce;
  133.  
  134. cout << endl;
  135.  
  136. while( chioce != 'n' );}
  137.  
  138. return EXIT_SUCCESS;
  139.  
  140. } // end of main
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 273
Reputation: Sci@phy will become famous soon enough Sci@phy will become famous soon enough 
Solved Threads: 42
Sci@phy's Avatar
Sci@phy Sci@phy is offline Offline
Posting Whiz in Training

Re: Syntax Error

 
1
  #2
Oct 19th, 2008
while( chioce != 'n' );} should actually be:
} while( chioce != 'n' );
Have a nice coding
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 21
Reputation: buddha527 is an unknown quantity at this point 
Solved Threads: 0
buddha527's Avatar
buddha527 buddha527 is offline Offline
Newbie Poster

Re: Syntax Error

 
0
  #3
Oct 19th, 2008
Thanks that worked perfectly
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC