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.

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

Recommended Answers

All 2 Replies

while( chioce != 'n' );} should actually be: } while( chioce != 'n' ); Have a nice coding :)

Thanks that worked perfectly

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.