Make a c++ program that will display netpay of employee by inputting the basic pay and overtime pay. It should compute first the gross pay which which is the sum of the input values and the tax which is 10% of the basic pay. The netpay is gross pay minus tax. Use a function for each computation.
#include <iostream>
using namespace std;
float GrossPay(float regular_hours, float rate_of_pay, float overtime_hours){
return (regular_hours * rate_of_pay) + (1.5 * overtime_hours * rate_of_pay);
}
float Tax(float grosspay){
return 0.1*grosspay;
}
float NetPay(float grosspay, float tax){
return grosspay - tax;
}
int main() {
float rate_of_pay, regular_hours, overtime_hours, grosspay, netpay, tax;
cout << "Enter the Hourly rate of pay: ";
cin >> rate_of_pay;
cout << "Enter the number of Regular hours: ";
cin >> regular_hours;
cout << "Enter the number of Overtime hours: ";
cin >> overtime_hours;
grosspay = GrossPay(regular_hours, rate_of_pay, overtime_hours);
tax = Tax(grosspay);
netpay = NetPay(grosspay, tax);
cout << "\nEmployee's Gross pay = " << grosspay << endl;
cout << "Tax = " << tax << endl;
cout << "Employee's Net pay = " << netpay << endl;
return 0;
}
Comments
Leave a comment