E
Eric Whittaker
here's my dilemma, on the program below, i am trying to calculate overtime
pay at time and a half, but instead of only counting the hours after 40, it
counts all hrs at that rate, how can i avoid this? thanks.
// figures hourly wages for employees
#include <iostream>
#include <conio.h>
using std::cout;
using std::cin;
using std::fixed;
#include <iomanip>
using std::setprecision;
//function main begins program execution
int main()
{
int total; // represents salary
int hrs; // represents hours worked
int rte; // represents rate paid
int ovr; // represents overtime pay
total = 0;
ovr = 0;
cout << "Enter hours worked (-1 to end):";
cin >> hrs;
while ( hrs != -1 ) {
cout << "\nEnter hourly rate of the worker:";
cin >> rte;
if ( hrs > 40 );
ovr = ( rte * .5 * hrs );
total = ( hrs * rte + ovr );
cout << "\nSalary is $" << setprecision ( 2 ) << fixed << total;
cout << "\nEnter hours worked (-1 to end:";
cin >> hrs;
if ( hrs < 0 );
break;
}
return 0;
}
pay at time and a half, but instead of only counting the hours after 40, it
counts all hrs at that rate, how can i avoid this? thanks.
// figures hourly wages for employees
#include <iostream>
#include <conio.h>
using std::cout;
using std::cin;
using std::fixed;
#include <iomanip>
using std::setprecision;
//function main begins program execution
int main()
{
int total; // represents salary
int hrs; // represents hours worked
int rte; // represents rate paid
int ovr; // represents overtime pay
total = 0;
ovr = 0;
cout << "Enter hours worked (-1 to end):";
cin >> hrs;
while ( hrs != -1 ) {
cout << "\nEnter hourly rate of the worker:";
cin >> rte;
if ( hrs > 40 );
ovr = ( rte * .5 * hrs );
total = ( hrs * rte + ovr );
cout << "\nSalary is $" << setprecision ( 2 ) << fixed << total;
cout << "\nEnter hours worked (-1 to end:";
cin >> hrs;
if ( hrs < 0 );
break;
}
return 0;
}