0
0
eneiad nassan
The code in this example displays the following output:
Welcome to our Payroll system Please enter your name: Please enter your employee code: Please choose your employee type: 1)Salaried 2)Hourly? (choose a number)\n
Your basic salary: $53,000.00 allowence = $53,000.00 gross_salary = $68,000.00 tax_deducation = $9,000.00 net_salary = $55,000.00
Employee name: John Doe Code: 111
allowence = $68,000.00 gross_salary = $94,800.00 tax_deducation = $13,800.00 net_salary = $71,200.00
Employee name: Jane Doe Code: 222
allowence = $94,800.00 gross_salary = $128,000.00 tax_deducation = $16,000.00 net_salary = $95,600.
#include <iostream>
using namespace std;
int main()
{
string name;
int code , n;
cout << "Welcome to our Payroll system\n";
cout << "Please enter your name:\n";
cin>> name;
cout << "Please enter your employee code:\n";
cin>> code;
cout<< "Please choose your employee type: 1)Salaried 2)Hourly? (choose a number)\n";
cin>> n;
if(n==1){
float salary, allowence , gross_salary , tax_deducation , net_salary ;
cout<< "Your basic salary:\n";
cin>> salary;
allowence = salary * 0.52;
gross_salary = salary + allowence;
tax_deducation = gross_salary * 0.30;
net_salary = gross_salary - tax_deducation;
cout<<" PAYSLIP ";
cout<< "\nEmployee name: "<< name <<" Code: "<< code;
cout<<"\n********************************************\n";
cout<<"allowence = " << allowence<<"\n";
cout<<"gross_salary = " << gross_salary<<"\n";
cout<< "tax_deducation = "<<tax_deducation<<"\n";
cout<< "net_salary = " << net_salary<<"\n";
}
else if (n == 2){
cout<<" PAYSLIP ";
cout<< "\nEmployee name: "<< name <<" Code: "<< code;
cout<<"\n********************************************\n";
cout<<"Earning:";
float numOfWoork , wage, overTime ;
char l;
cout<<"How often are you paid? A)Weekly B) Monthly? (chose letter)\n";
cin>> l;
cout<<"The number of hours you have worked per week?\n";
cin>> numOfWoork;
cout<<"What is your wage per hour (in dollars)?\n";
cin>> wage;
cout<< "Please enter the number of overtime hours:\n";
cin>> overTime;
if (l == 'A'){
cout<< "Salary per week: ("<< numOfWoork<<"hrs * $"<< wage<<") = "<< "$"<<numOfWoork*wage<<"\n";
cout<<"Over time: (1.5 * "<< overTime << " hrs * $" <<wage <<") = " <<"$"<< 1.5*overTime*wage<<"\n";
cout<<"Net Salary = $" << numOfWoork*wage + 1.5*overTime*wage;
}
}
return 0;
}