assignment #3

assignment #3 - tax = MarriedTax(income); t // display 2...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Amanda Drobney October 24,2010 Assignment #3 A #include <iostream> #include <iomanip> # using namespace std; u // calculate the tax for single double SingleTax( double income); // calculate the tax for married double MarriedTax( double income); d int main() { double income; char type; double tax; d // ask the user to enter the income cout << "Enter your income: "; cin >> income; while (income <= 0) { cout << "Enter positive number: "; cin >> income; } // ask the user to enter the status cout << "Enter the status(S for single, M for married): "; cin >> type; { cout << "Enter 'S' or 'M': "; cin >> type; } // calculate the tax if (type == 'S') tax = SingleTax(income); else
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: tax = MarriedTax(income); t // display 2 digits after point cout &lt;&lt; fixed &lt;&lt; setprecision(2); c // display the result cout &lt;&lt; &quot;The tax is $&quot; &lt;&lt; tax &lt;&lt; endl; c return 0; } double SingleTax( double income) { if (income &lt;= 21450) // 0 - 21450 return income * 0.15; else if (income &lt;= 51900) // 21450 - 51900 return 3217.5 + (income - 21450) * 0.28; r // &gt; 51900 return 11743.5 + (income - 51900) * 0.31; } double MarriedTax( double income) { if (income &lt;= 35800) // 0 - 35800 return income * 0.15; else if (income &lt;= 86500) // 35800 - 86500 return 5370 + (income - 35800) * 0.28; r // &gt; 35800 return 19566 + (income - 86500) * 0.31; }...
View Full Document

Page1 / 2

assignment #3 - tax = MarriedTax(income); t // display 2...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online