cuong5985
asked on
Find the gross of an employee
Topic
Ask the user to input the number of hours a given employee has worked along with the rate of pay per hour. (make sure no one has worked more than 80 hours in a week as I think this is illegal!) Output this information along with Gross pay for this employee in a table-like output:
Hours Rate Gross OverTime?
15 10 150 No
Hours Rate Gross OverTime?
41 10 415 Yes
And this is my program:
#include <iostream.h>
#include <stdlib.h>
#define DEBUG_ON false
double CalcGross(double hours, double rate);
int main()
{
double rate, hours, gross;
cout <<"Enter rates: ";
cin >>rate;
cout <<"Enter hours: ";
cin >>hours;
gross = CalcGross(hours, rate);
cout<<"With "<<hours<<" hours at "<<rate;
cout << " dollars per hour, you will be paid "<<gross<<" dollars"<<endl;
system("PAUSE");
return 0;
}
double CalcGross(double hours, double rate)
/************************* ********** ********** ********** ********** ****
Function Name: CalcGross
Purpose: Calculates Gross from Hours and Rate.
Arguments: Hours, Rate
Returns: gross and IO include
************************** ********** ********** ********** ********** ***/
{
if (DEBUG_ON)
{
cout<<endl<<"CalcGross: Hours: "<<hours<< "Rate is: "<<rate;
cout<<endl;
}
if (hours > 40)
{
cout <<"Overtime: Yes ";
cout <<endl;
}
else
{
cout <<"Overtime: No ";
cout <<endl;
}
return hours * rate;
}
This program work quite right, but my teacher doesnt accepted, can someone help me to figure it out.
Ask the user to input the number of hours a given employee has worked along with the rate of pay per hour. (make sure no one has worked more than 80 hours in a week as I think this is illegal!) Output this information along with Gross pay for this employee in a table-like output:
Hours Rate Gross OverTime?
15 10 150 No
Hours Rate Gross OverTime?
41 10 415 Yes
And this is my program:
#include <iostream.h>
#include <stdlib.h>
#define DEBUG_ON false
double CalcGross(double hours, double rate);
int main()
{
double rate, hours, gross;
cout <<"Enter rates: ";
cin >>rate;
cout <<"Enter hours: ";
cin >>hours;
gross = CalcGross(hours, rate);
cout<<"With "<<hours<<" hours at "<<rate;
cout << " dollars per hour, you will be paid "<<gross<<" dollars"<<endl;
system("PAUSE");
return 0;
}
double CalcGross(double hours, double rate)
/*************************
Function Name: CalcGross
Purpose: Calculates Gross from Hours and Rate.
Arguments: Hours, Rate
Returns: gross and IO include
**************************
{
if (DEBUG_ON)
{
cout<<endl<<"CalcGross: Hours: "<<hours<< "Rate is: "<<rate;
cout<<endl;
}
if (hours > 40)
{
cout <<"Overtime: Yes ";
cout <<endl;
}
else
{
cout <<"Overtime: No ";
cout <<endl;
}
return hours * rate;
}
This program work quite right, but my teacher doesnt accepted, can someone help me to figure it out.
ASKER
I dont know, he already graded for me and gave me 3/10. I wonder that i follow what he said in the topic that he gave me. But i dont know he still gave me a bad grade, can you help me to fix it. He doesnt gave me a comment about this, exactly i was on spring break so i cant ask him.
<iostream.h> is not part of the C++ standard, so you're code is not portable.
Should use <iostream> instead, along with
using namespace std;
From reading the assignment, I think he wanted you to do error checking for correct input range at the point where you're getting the input.
Your error checking is in the CalcGross() function, and it's to late in the code to do anything about the wrong input at that point.
Should use <iostream> instead, along with
using namespace std;
From reading the assignment, I think he wanted you to do error checking for correct input range at the point where you're getting the input.
Your error checking is in the CalcGross() function, and it's to late in the code to do anything about the wrong input at that point.
>>Output this information along with Gross pay for this employee in a table-like output:
A table-like output would usually have a header and outlines for each column.
A table-like output would usually have a header and outlines for each column.
ASKER
Can you help me to do this, cause i just want to know so i will do it better on the test, anyway, the homework already graded?
Hi cuong,
Axter is correct about iostream.h in my school teacher reduce overal score for iostream.h Use <iostream> instead.
Then points are reduces when source code is not well documented. Try put more comments inside your code. Nobody can blame you that you put there too much comments. Another points are reduces for style as output. Think bout output what your program produces an make it more nice. The last think is . When I run your program I got this error:
sh: line 1: PAUSE: command not found
then I compile it without system("PAUSE"); line and works fine. For this points can be also reduced.
good luck
./lubo
Axter is correct about iostream.h in my school teacher reduce overal score for iostream.h Use <iostream> instead.
Then points are reduces when source code is not well documented. Try put more comments inside your code. Nobody can blame you that you put there too much comments. Another points are reduces for style as output. Think bout output what your program produces an make it more nice. The last think is . When I run your program I got this error:
sh: line 1: PAUSE: command not found
then I compile it without system("PAUSE"); line and works fine. For this points can be also reduced.
good luck
./lubo
here is warning what I got when compile with <iostream.h>
#warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples in clude substituting the <X> header for the <X.h> header for C++ includes, or <sst ream> instead of the deprecated header <strstream.h>.
#warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples in clude substituting the <X> header for the <X.h> header for C++ includes, or <sst ream> instead of the deprecated header <strstream.h>.
to Axter :
Axter you have very nice profile. I like it. Any hints how to becomme excelent c++ coder as you are? :-))
cheers
Axter you have very nice profile. I like it. Any hints how to becomme excelent c++ coder as you are? :-))
cheers
>>Any hints how to becomme excelent c++ coder as you are? :-))
Practice, practice, practice.
Practice, practice, practice.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
> >This program work quite right, but my teacher doesnt accepted, can
> >someone help me to figure it out.
What doesn't youre teacher not accept?
Please post more specific question.
David Maisonave :-)
Cheers!