fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. double income, rate = 0, diff = 0;
  6. cout << "Enter net income: ";
  7. cin >> income;
  8.  
  9. if (income <= 560000) {
  10. rate = 0.05; diff = 0;
  11. } else if (income <= 1260000) {
  12. rate = 0.12; diff = 39200;
  13. } else if (income <= 2420000) {
  14. rate = 0.20; diff = 140000;
  15. } else if (income <= 4530000) {
  16. rate = 0.30; diff = 382000;
  17. } else {
  18. rate = 0.40; diff = 835000;
  19. }
  20.  
  21. double tax = (income * rate) - diff;
  22. if (tax < 0) tax = 0;
  23.  
  24. cout << "Tax Rate: " << (rate * 100) << "%" << endl;
  25. cout << "Tax Payable: $" << tax << endl;
  26.  
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5312KB
stdin
4600
stdout
Enter net income: Tax Rate: 5%
Tax Payable: $230