Taxes examples: Taxes A Notes // Purpose: compute income tax //   using simple numbers //    table: income, rate, max from previous //     0-10K   5%     0 //    10K-30K  10%    500 //    30K-70K  15%    500 + 2000 = 2500 //     > 70K   20%    2500 + 6000 = 8500

Code:

// File: taxesA.cpp
// Date: Sep 10, 2014
// Author: Nicholas Duchon
// Purpose: compute income tax
//   using simple numbers
//    table: income, rate, max from previous
//     0-10K   5%     0
//    10K-30K  10%    500
//    30K-70K  15%    500 + 2000 = 2500
//     > 70K   20%    2500 + 6000 = 8500

#include <stdio.h>
#include <iostream>
#include <string>
using namespace std;

int main () {
double income, tax;

cout << "Enter income: ";
cin >> income;

if (income <= 10000) tax = income * 0.05;
if (income > 10000 && income <= 30000) tax = 500 + (income - 10000) * 0.10;
if (income > 30000 && income <= 70000) tax = 2500 + (income - 30000) * 0.15;
if (income > 70000) tax = 8500 + (income - 70000) * 0.20;

printf ("Tax on \$%.2f is \$%.2f\n", income, tax);

cout << "Bye" << endl;
// sytem ("Pause"); // Visual C++ pause
} // end main

Testing:

Enter income: 30001
Tax on \$30001.00 is \$2500.15
Bye

By: Nicholas Duchon

end.