You are an accountant setting up a payroll system based on Table, which shows five different ranges for salaries up to Rs.150, 000.00. Each table line shows the base tax amount (column2) and tax percentage (column3) for a particular salary range (column1).
Write a function that taken person’s salary and calculate the tax due by adding the base tax to the product of the percentage times the excess salary over the minimum salary for that range
#include <iostream>
using namespace std;
double calcTax(double salary){
double base_tax, minimum, percentage;
cout<<"Input base tax: ";
cin>>base_tax;
cout<<"Enter tax percentage for this range: ";
cin>>percentage;
cout<<"Input the minimum salary for this range: ";
cin>>minimum;
return base_tax + percentage / 100 * (salary - minimum);
}
int main(){
double salary;
cout<<"Input salary: ";
cin>>salary;
cout<<"Total tax: "<<calcTax(salary)<<endl;
return 0;
}
Comments
Leave a comment