#include <iostream>
Using namespace std;
int main ();
{
cout << "What is the mean amount you work/week?" << endl;
if (input <= 40)
cout << "Your salary is $8.00/hour";
cin >> a1;
if (a1 <= 0)
cout << "";
cin >> a2;
if (a2 >= 40)
cout << a3
cin >> a3;
cout << "" << endl;
else
cout << " Better luck next time.- the correct answer is " << add << endl;
return 0;
I'm trying to write a C++
program to compute and display a person’s salary as determined by the following expressions:
If hours worked <= 40
, the person receives $8/hour
otherwise,
Person receives the first 40hrs @ $8/hr
remaining hrs at 1.5x
basic rate.
Program should request:
1) hours worked (input)
2) display the salary earned (output).
Use a constant variable for basic rate so the program can be updated easily when hourly rates change.
Give appropriately input/output.
Test program several x
with hrs below, =
, and above 40
.
Any direction will be greatly appreciated!
Get some good books on C++, Check out The Definitive C++ Book Guide and List
As per your code. This is what it should be
#include <iostream>
int main () {
int hours = 0;
int rate = 8;
std::cout << "Enter number of working hours?";
std::cin >> hours;
int pay = hours * rate;
if (40 < hours) {
pay += (hours - 40) * (rate / 2);
}
std::cout << "Total Pay" << pay << std::endl;
return 0;
}