### HELP

THIS IS MY CODE

 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 #include #include #include using namespace std; int main() { // declare variables int salary; // income int status; int single; int married; string taxFee ; double taxPercent ; double tax; // get input from user cout << "what is your income?"; cin >> salary; cout << "married or single"; cin >> single || married // processing if ( status == single) if ((salary >= 0) && (salary < 25000)) { taxFee = "single first class tax"; taxPercent = .10; } else if ((salary >= 25000) && (salary < 75000)) { taxFee = "single second class tax"; taxPercent = .20; } else if ((salary >= 75000) && (salary < 125000)) { taxFee = "single third class tax"; taxPercent = .30; } else if (salary <= 125,000) { taxFee = "single fourth class tax"; taxPercent = .40; } if ( status == married) if ((salary >= 0) && (salary < 25000)) { taxFee = "married first class tax"; taxPercent = .08; } else if ((salary >= 25000) && (salary < 75000)) { taxFee = "married second class tax"; taxPercent = .15; } else if ((salary >= 75000) && (salary < 125000)) { taxFee = "married third class tax"; taxPercent = .25; } else if (salary <= 125,000) { taxFee = "married fourth class tax"; taxPercent = .30; } // do processing tax = salary * taxPercent; // output results cout << "based on the salary" << taxFee << " for \$" << taxPercent << endl; cout << "your total tax is \$" << tax << " per month" << endl; system("PAUSE"); return 0; }

HOW DO I FIX IT
Last edited on
Fix what? What problem are you having?
First things first: not that I hold it against you, but you technically aren't supposed to post forum questions called "HELP".

Now, first, go with cin.get(); instead of that dreadful system("PAUSE"); and then your function will not give non-Bloodshed coders conniptions.

Second. you cannot cin>>single || married. I know your motives were right, but how is the poor processor supposed to choose? Go with a standard char choice and make the choices "s" or "m". Then take the answer and use it to assign either true or false to a bool called isMarried. Then get rid of all your status, single, or married stuff, because the processor can't understand that.

An anonymous coder wrote:
A program is like a car wash that washes your car, but leaves it soapy. It hasn't been told to rinse.

Repost with corrections:
 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 #include #include #include using namespace std; int main() { // declare variables int salary; // income bool isMarried; char choice; string taxFee; double taxPercent; double tax; // get input from user cout << "what is your income?"<> salary; cout << "married or single? (M/S)"<> choice; if(choice == 'm' || choice == 'M') isMarried = true; else if(choice == 's' || choice == 'S') isMarried = false; else { cout<<"That wasn't a choice. Please restart program."; return 0; } // processing if (!isMarried) { if ((salary >= 0) && (salary < 25000)) { taxFee = "single first class tax"; taxPercent = .10; } else if ((salary >= 25000) && (salary < 75000)) { taxFee = "single second class tax"; taxPercent = .20; } else if ((salary >= 75000) && (salary < 125000)) { taxFee = "single third class tax"; taxPercent = .30; } else if (salary <= 125,000) { taxFee = "single fourth class tax"; taxPercent = .40; } } else if (isMarried) { if ((salary >= 0) && (salary < 25000)) { taxFee = "married first class tax"; taxPercent = .08; } else if ((salary >= 25000) && (salary < 75000)) { taxFee = "married second class tax"; taxPercent = .15; } else if ((salary >= 75000) && (salary < 125000)) { taxFee = "married third class tax"; taxPercent = .25; } else if (salary <= 125,000) { taxFee = "married fourth class tax"; taxPercent = .30; } } // do processing tax = salary * taxPercent; // output results cout << "based on the salary" << taxFee << " for \$" << taxPercent << endl; cout << "your total tax is \$" << tax << " per month" << endl; cin.get(); return 0; }

Hope I helped.
Last edited on
Topic archived. No new replies allowed.