n ()
{
int i,rate, overtime,number;
double base;
string name;
char user;
//Formula
base= rate*number;
double salary = rate * number;
for (i=0; i==i;++i)
{
cout << " What is the first name of the employee?: " ;
cin >> name ;
cout <<"how many hours did " << name << " work ?";
cin >> number;
while ( number <0)
{
cout << "please enter a valid value for hours worked ";
cin >> number;
}
cout << " please enter your rate of your employment?";
cin>> rate;
while ( rate<0)
{
cout << " please enter a valid value for rate" ;
cin >>rate;
}
//Formula
base= 40*rate;
salary = rate * number;
if (number > 40)
{
overtime = (number - 40) * 1.5 * rate;
}
elseif (number <= 40)
{
salary = rate * number;
}
cout
<< "\n\t________________________________________________________"
<< "\n\t|"; cout<< "\tTotal number of hours :"<<number <<"\t\t\t|"
<< "\n\t|"; cout<< "\tPay rate " << rate <<"\t\t\t\t\t|"
<< "\n\t|"; cout<< "\tNumber of hours (overtime) "<< (number-40) << "\t\t\t|"
<< "\n\t|"; cout<< "\tBase salary :"<< base <<"\t\t\t\t|"
<< "\n\t|"; cout<<"\tOvertime pay : " << overtime <<"\t\t\t\t|"
<< "\n\t|"; cout<<"\tTotal pay : "<< (base+overtime)<<"\t\t\t\t|"
<<"\n\t________________________________________________________"<<endl;
do
{
cout<< "\nDo you want to add more employee(s) to calculate";
cout<< "please enter Y for yes or N for no";
cin >> user;
}
while((user =='Y')&&(user =='y')||(user!='N')&&(user !='n'));
}
system ("pause");
return 0;
}
#include <iostream>
#include <string>
usingnamespace std;
int main ()
{
int i,rate, overtime,number;
double base;
string name;
char user;
//Formula
base= rate*number;
double salary = rate * number;
for (i=0; i==i;++i)
{
cout << " What is the first name of the employee?: " ;
cin >> name ;
cout <<"how many hours did " << name << " work ?";
cin >> number;
while ( number <0)
{
cout << "please enter a valid value for hours worked ";
cin >> number;
}
cout << " please enter your rate of your employment?";
cin>> rate;
while ( rate<0)
{
cout << " please enter a valid value for rate" ;
cin >>rate;
}
//Formula
base= 40*rate;
salary = rate * number;
if (number > 40)
{
overtime = (number - 40) * 1.5 * rate;
}
elseif (number <= 40)
{
salary = rate * number;
}
cout
<< "\n\t________________________________________________________"
<< "\n\t|"; cout<< "\tTotal number of hours :"<<number <<"\t\t\t|"
<< "\n\t|"; cout<< "\tPay rate " << rate <<"\t\t\t\t\t|"
<< "\n\t|"; cout<< "\tNumber of hours (overtime) "<< (number-40) << "\t\t\t|"
<< "\n\t|"; cout<< "\tBase salary :"<< base <<"\t\t\t\t|"
<< "\n\t|"; cout<<"\tOvertime pay : " << overtime <<"\t\t\t\t|"
<< "\n\t|"; cout<<"\tTotal pay : "<< (base+overtime)<<"\t\t\t\t|"
<<"\n\t________________________________________________________"<<endl;
cout<< "\nDo you want to add more employee(s) to calculate";
cout<< "please enter Y for yes or N for no ";
cin >> user;
if(user == 'N' || user == 'n') break;
}
system ("pause");
return 0;
}
sorry, the main function ()- is there. I just didnt paste it from my complier. Also, i used a Do-while loop but the program is not exiting when i input the request
sure,
when I put 41, the programs runs correctly and the output is correct, however,
when running the program with 40 hours, it still calculates it with overtime pay. I would like the program to only calculate when the hours are greater than 40. I hope I explain correctly