In: Computer Science
write a program to calculate and print payslips
write program that calculates and prints payslips. User inputs are the name of employee, numbers of hours worked and hourly rate
c++ language
#include <iostream>
using namespace std;
int main() {
string empName;
int hours;
double payRate;
cout<<"Enter the name of employee : ";
cin>>empName;
cout<<"\nEnter the number of hours worked :
";
cin>>hours;
cout<<"\nEnter hourly rate : ";
cin>>payRate;
double wages = hours*payRate;
cout<<endl<<endl;
cout<<"---------
PAYSLIP-----------"<<endl;
cout<<"Employee Name :
"<<empName<<endl;
cout<<"Hours Worked :
"<<hours<<endl;
cout<<"Hourly Pay Rate :
"<<payRate<<endl;
cout<<"Wages :
$"<<wages<<endl;
cout<<"-----------------------------"<<endl;
return 0;
}
Output:
Enter the name of employee : John
Enter the number of hours worked : 38
Enter hourly rate : 12.56
--------- PAYSLIP-----------
Employee Name : John
Hours Worked : 38
Hourly Pay Rate : 12.56
Wages : $477.28
-----------------------------
Do ask if any doubt. Please upvote.