Question
Hi this is my code I'm trying to figure out why it isn't running fluently and why I can't get above a fifty this is
Hi this is my code I'm trying to figure out why it isn't running fluently and why I can't get above a fifty this is language C++ thanks in advance and I will rate.
#include #include using namespace std; void getData(int numPerson, int numChildren, double salary, int pension, double tax); double taxAmount(int numPerson, double salary, int pension, double tax, double totalTax); int main () { int numberOfPerson = 0; int numberOfChildren = 0; int pensionPercent = 0; double grossIncome = 0; double taxableIncome = 0; double taxOwed = 0; double taxPayment; getData(numberOfPerson, numberOfChildren, grossIncome, pensionPercent, taxableIncome); taxPayment = taxAmount(numberOfPerson, grossIncome, pensionPercent, taxableIncome, taxOwed); cout << "The tax is: " << taxPayment << endl; return 0; } void getData(int &numPerson, int &numChildren, double salary, int pension, double tax) { char maritalStatus; cout << "Enter marital status. M = Married & S = Single. "; cin >> maritalStatus; cout << endl; if (maritalStatus == 'm' || maritalStatus == 'M') { cout << "Any children under the age of 14? "; cin >> numChildren; cout << endl; numPerson = 2 + numChildren; } else if (maritalStatus == 's' || maritalStatus == 'S') { numPerson = 1; } cout << "Enter gross income. If married and both spouses are working, enter combine income. "; cin >> salary; cout << endl; cout << "Enter the percentage of gross income contributed to the pension. "; cin >> pension; cout << endl; } double taxAmount(int numPerson, double salary, int pension, double tax, double totalTax) { const int PERSONAL_EXEMPTION = 1500; const int SINGLE_EXEMPTION = 4000; const int MARRIED_EXEMPTION = 7000; if (numPerson == 1) { tax = salary - PERSONAL_EXEMPTION - SINGLE_EXEMPTION - salary * (pension / 100); } else if (numPerson >= 2) { tax = salary - MARRIED_EXEMPTION - (PERSONAL_EXEMPTION * numPerson) - salary * (pension / 100); } if (tax >= 0 && tax <= 15000) { totalTax = tax * 0.15; } else if (tax >= 15001 && tax <= 40000) { totalTax = 2250 + (tax - 15000) * 0.25; } else if (tax >= 40001) { totalTax = 8460 + (tax - 40000) * 0.35; } return totalTax; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started