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 <= 520000) {
  10. rate = 0.05; diff = 0;
  11. } else if (income <= 1170000) {
  12. rate = 0.12; diff = 36400;
  13. } else if (income <= 2350000) {
  14. rate = 0.20; diff = 130000;
  15. } else if (income <= 4400000) {
  16. rate = 0.30; diff = 365000;
  17. } else if (income <= 10000000) {
  18. rate = 0.40; diff = 805000;
  19. } else {
  20. rate = 0.45; diff = 1305000;
  21. }
  22.  
  23. double tax = (income * rate) - diff;
  24. if (tax < 0) tax = 0;
  25.  
  26. cout << "Tax Rate: " << (rate * 100) << "%" << endl;
  27. cout << "Tax Payable: $" << tax << endl;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
Enter net income: Tax Rate: 5%
Tax Payable: $3.47653e-311