Hi, could someone please help me with this error message, I 've included my program along with the error message. Thank you.

Compiling...
C:\Documents and Settings\\Lab7\Lab7.cpp(33) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

Lab7.obj - 1 error(s), 0 warning(s)

#include <iostream>
using namespace std;
double Pay(double rate, double hours);  

int main()
{  
   cout << "The pay for 30 hours at  $8.50 is $" << Pay(8.50, 30) << endl;
   cout << "The pay for 40 hours at $12.00 is $" << Pay(12.00, 40) << endl;
   cout << "The pay for 50 hours at $10.00 is $" << Pay(10.00, 50) << endl;
   return 0;
}
double Pay(double rate, double hours)   // No semicolon, this is the function
{										// that you write.   
   int main();
 
    double Overtime_pay, Gross_pay, pay_rate, regular_pay;

	if (hours > 40)
	{
	regular_pay = 40 * pay_rate;
	Overtime_pay = (hours - 40.0) * 1.5 * pay_rate;
	Gross_pay = regular_pay + Overtime_pay;
	}
	else
	{
	regular_pay = 40 * pay_rate;
	Gross_pay = regular_pay + Overtime_pay;


{

Hi, could someone please help me with this error message, I 've included my program along with the error message. Thank you.

Compiling...
C:\Documents and Settings\\Lab7\Lab7.cpp(33) : fatal error C1004: unexpected end of file found
Error executing cl.exe.

Lab7.obj - 1 error(s), 0 warning(s)

#include <iostream>
using namespace std;
double Pay(double rate, double hours);  

int main()
{  
   cout << "The pay for 30 hours at  $8.50 is $" << Pay(8.50, 30) << endl;
   cout << "The pay for 40 hours at $12.00 is $" << Pay(12.00, 40) << endl;
   cout << "The pay for 50 hours at $10.00 is $" << Pay(10.00, 50) << endl;
   return 0;
}
double Pay(double rate, double hours)   // No semicolon, this is the function
{										// that you write.   
   int main();
 
    double Overtime_pay, Gross_pay, pay_rate, regular_pay;

	if (hours > 40)
	{
	regular_pay = 40 * pay_rate;
	Overtime_pay = (hours - 40.0) * 1.5 * pay_rate;
	Gross_pay = regular_pay + Overtime_pay;
	}
	else
	{
	regular_pay = 40 * pay_rate;
	Gross_pay = regular_pay + Overtime_pay;

        {

Is this the whole program? The error suggests that you (and if this is the whole program, it is definitely the reason, along with some other errors) have a starting bracket { with no corresponding ending bracket }.

Regardless, get rid of line 14 and you need to return a value in your Pay function.

Hi, could you show me or tell me how to return the value to the pay function please, thank you.

Hi, could you show me or tell me how to return the value to the pay function please, thank you.

You have two threads going on basically the same topic. In the future, please only have one. Having two can cause two people to give the same advice without knowing someone else has already done so.

double Pay(double rate, double hours)   // No semicolon, this is the function
{										// that you write.   
   int main();
 
    double Overtime_pay, Gross_pay, pay_rate, regular_pay;

	if (hours > 40)
	{
	regular_pay = 40 * pay_rate;
	Overtime_pay = (hours - 40.0) * 1.5 * pay_rate;
	Gross_pay = regular_pay + Overtime_pay;
	}
	else
	{
	regular_pay = 40 * pay_rate;
	Gross_pay = regular_pay + Overtime_pay;

        {

See my former post. You need to solve the brackets problem before trying to return anything. Thus I can't tell you how to return the value because I don't know what value you want to return (Gross_pay ?). If that is the value you want to return, you could do this:

double Pay(double rate, double hours)
{
    double Overtime_pay, Gross_pay, pay_rate, regular_pay;
    // code to calculate Gross_pay
    return Gross_pay;
}
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.