I am trying to modify a tax program so that I only have one line that start with the variable "tax = ...".
The original statements are commented out so that you may see what the original program looked like. What I don't know how to do is to put the calculations into one line so that the output is the tax.
Please help!
#include <iostream>
#include <string>
using namespace std;
int main()
{
const double SINGLE_LEVEL1 = 21450.00;
const double SINGLE_LEVEL2 = 51900.00;
const double SINGLE_TAX1 = 3217.50;
const double SINGLE_TAX2 = 11743.50;
const double MARRIED_LEVEL1 = 35800.00;
const double MARRIED_LEVEL2 = 86500.00;
const double MARRIED_TAX1 = 5370.00;
const double MARRIED_TAX2 = 19566.00;
const double RATE1 = 0.15;
const double RATE2 = 0.28;
const double RATE3 = 0.31;
double income;
double cutoff15;
double cutoff28;
double cutoff31;
double tax;
string marital_status;
cout << "Please enter your income: ";
cin >> income;
cout << "Please enter s for single, m for married: ""\n";
cin >> marital_status;
if (marital_status == "s")
{
if (income <= SINGLE_LEVEL1)
cutoff15 = RATE1 * income; //tax = RATE1 * income;
else if (income <= SINGLE_LEVEL2)
cutoff28 = SINGLE_TAX1 + RATE2 * (income - SINGLE_LEVEL1);//tax = SINGLE_TAX1 + RATE2 * (income - SINGLE_LEVEL1);
else
cutoff31 = SINGLE_TAX2 + RATE3 * (income - SINGLE_LEVEL2);//tax = SINGLE_TAX2 + RATE3 * (income - SINGLE_LEVEL2);
}
if (marital_status == "m")
{
if (income <= MARRIED_LEVEL1)
cutoff15 = RATE1 * income;//tax = RATE1 * income;
else if (income <= MARRIED_LEVEL2)
cutoff28 = MARRIED_TAX1 + RATE2 * (income - MARRIED_LEVEL1);//tax = MARRIED_TAX1 + RATE2 * (income - MARRIED_LEVEL1);
else
cutoff31 = MARRIED_TAX2 + RATE3 * (income - MARRIED_LEVEL2);//tax = MARRIED_TAX2 + RATE3 * (income - MARRIED_LEVEL2);
}
//cout << "The tax is $" << tax << "\n";
return 0;
}