The Calculation isn't Quite Right
#include <iostream> #include <cmath> #include <string> using namespace std; //getName() string getName(string firstname, string lastname) { string fullname; fullname = firstname + " " + lastname; } float getHours(float Mon, float Tue, float Wed, float Thu, float Fri) { float totalHours; totalHours = Mon + Tue + Wed + Thu + Fri; cout << "Total hours worked: " << totalHours << endl; } float printPay(string fullname, float totalHours) { float hourlyPayRate; float difference, totalPay, totalPayPlusDifference; cout << "Enter hourly pay rate: " << endl; cin >> hourlyPayRate; totalPay = totalHours * hourlyPayRate; if (totalHours > 40) { difference = totalPay * 0.10; totalPayPlusDifference = totalPay + difference; cout << fullname << ", your pay is R" << totalPayPlusDifference << endl; } else if(totalHours < 40) { difference = totalPay * 0.10; totalPayPlusDifference = totalPay - difference; cout << fullname << ", your pay is R" << totalPayPlusDifference << endl; } else cout << fullname << ", your pay is R" << hourlyPayRate << endl; return 0; } int main() { string firstname, lastname,a, c, fullname; float Mon, Tue, Wed, Thu, Fri, totalHours, b; cout << "Enter your first name: " << endl; cin >> firstname; cout << "Enter your last name: " << endl; cin >> lastname; fullname = firstname + " " + lastname; a = getName(firstname, lastname); cout << "Enter the hours you worked for each day of the week (Monday-Friday)" << endl << endl; cout << "Monday: "; cin >> Mon; cout << "Tuesday: "; cin >> Tue; cout << "Wednesday: "; cin >> Wed; cout << "Thursday: "; cin >> Thu; cout << "Friday: "; cin >> Fri; b = getHours(Mon, Tue, Wed, Thu, Fri); c = printPay(fullname, b); return 0; }