/* ALGORITHM get hours worked get hourly rate get overtime status regular pay = hours * rate if they get overtime and they worked more than 40 hours overtime pay = (hours - 40 ) * rate / 2 total pay = regular pay + overtime pay print results EXAMPLE we work 46 hours at $10 per hour 46 * 10 + 6 * 5 */ #include #include using namespace std; const float HOURS_PER_WEEK {40}; int main() { float hourlyRate {0}, hoursWorked {0}, regularPay {0}, overtimePay {0}, totalPay{0}; bool getsOvertimePay {false}; char answer; cout << "Enter your hourly rate of pay: " ; cin >> hourlyRate; cout << endl; cout << "Enter the number of hours worked: "; cin >> hoursWorked; cout << endl; cout << "Do you get overtime pay? (Y/N) "; cin >> answer; if ('Y' == answer or 'y' == answer) { getsOvertimePay = true; } /* if (getsOvertimePay) { cout << "You get overtime pay" << endl; } else { cout << "You don't get overtime pay " << endl; } */ regularPay = hourlyRate * hoursWorked; // calculate overtime Pay if (hoursWorked > HOURS_PER_WEEK and getsOvertimePay){ overtimePay = hourlyRate/2.0f * (hoursWorked - HOURS_PER_WEEK); /*cout << "You worked " << hoursWorked - HOURS_PER_WEEK << " overtime hours" << endl; cout << "That will pay $" << overtimePay << endl; */ } totalPay = regularPay + overtimePay; cout << "Your pay is $" << totalPay << endl; cout << "\tRegular Pay $" << regularPay << endl; cout << "\tOvertime Pay $" << overtimePay << endl; return 0; }