I need the following program to run the functions I wrote.I struggle to remember how to let the printPay() get the variable fullname(struggle with strings).
#include <iostream>
#include <string>
usingnamespace std;
// Calculates the pay , if toatlhours >40 +10& bonus but if <40 deduct 10%
float printPay(float totalhours, std::string fullname){
float constRate=120.35;
int bonus= 10;
float pay=totalhours*constRate;
float bonusamout=bonus*pay/100;
float finalpay;
if (totalhours >40){
;
finalpay=bonusamout + pay;
cout<< fullname << "recieves a bonus of R" << bonusamout <<"that is included in total pay for week :R" << finalpay << endl;}
elseif (totalhours==40){
finalpay=pay;
cout<< fullname << "gets total pay for week :R" << finalpay<< endl;}
else {
finalpay=pay-bonusamout;
cout<< fullname << "gets R"<< bonusamout<< "deducted from total pay for week :R" << finalpay<< endl;}
}
// Calculate the total of hours worked in a week and reutn totalhours
float getHours(){
int mhours;
int thours;
int whours;
int tThours;
int fhours;
cout << "How many hours did the employee work on Monday?"<< endl;
cin >> mhours;
cout << "How many hours did the employee workwork on Tuesday?"<< endl;
cin >> thours;
cout << "How many hours did the employee workwork on Wensday?"<< endl;
cin >> whours;
cout << "How many hours did the employee workwork on Thursday?"<< endl;
cin >> tThours;
cout << "How many hours did the employee workwork on Friday?"<< endl;
cin >> fhours;
float totalhours=mhours+thours+whours+tThours+fhours;
return totalhours;
}
//Function to combine first name and last name return fullname
std::string getName()
{
std::string fname;
std::string sname;
cout<< "What is the employees first name" << endl;
cin >> fname;
cout << "what it the employess last name" << endl;
cin>> sname;
std::string fullname=fname+" "+sname;
return fullname;
}
main(){
std::string fullname;
float totalhours;
getName();
getHours();
printPay(totalhours,fullname);
return 0;}