Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void tax(string answer, int inc)
- {
- double tax = 0;
- if (answer == "Yes" || answer == "yes")
- {
- //single
- if (inc > 0 && inc <= 21400)
- {
- tax = inc * 0.15;
- cout << tax;
- }
- else if (inc >21450 && inc <= 51900)
- {
- tax = 3217.50 + (inc- 21450.00) * 0.28;
- cout << tax;
- }
- else if (inc > 51900)
- {
- tax = 11743.00 + (inc - 51900.00) * 0.31;
- cout << tax;
- }
- else
- {
- cout << "Incorrect income value. Try again.";
- }
- }
- else if (answer == "No" || answer == "no")
- {
- //married
- if (inc > 0 && inc <= 35800)
- {
- tax = inc * 0.15;
- cout << tax;
- }
- else if (inc > 35800 && inc <= 86500)
- {
- tax = 5370.00 + (inc - 35800.00) * 0.28;
- cout << tax;
- }
- else if (inc > 86500)
- {
- tax = 19566.00 + (inc - 86500.00) * 0.31;
- cout << tax;
- }
- else
- {
- cout << "Incorrect income value. Try again.";
- }
- }
- else
- {
- cout << "Incorrect relationship status. Try again.";
- }
- }
- int main()
- {
- string answer;
- int inc;
- cout << "Are you single? \n";
- cin >> answer;
- cout << "What is your income? \n";
- cin >> inc;
- cout << "Your tax is: $";
- tax(answer, inc);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement