fork download
  1. // Nicolas Ruano CS1A Chapter 2, Pp. 81, #3
  2.  
  3. /*************************************************************************
  4. *
  5. *------------------------------------------------------------------------*
  6. * Output is where it displays different sales taxes that are being *
  7. * calculated *
  8. * -----------------------------------------------------------------------*
  9. * Input *
  10. * The diefferent sales taxes being provided with how much cost *
  11. * *
  12. * Output *
  13. * The resolved answer of the taxes calculated *
  14. *************************************************************************/
  15.  
  16. #include <iostream>
  17. using namespace std;
  18.  
  19. int main() {
  20. // Purchase amount
  21. double purchase = 52.0;
  22.  
  23. // Tax rates
  24. double stateTaxRate = 0.04; // 4%
  25. double countyTaxRate = 0.02; // 2%
  26.  
  27. // Compute taxes
  28. double stateTax = purchase * stateTaxRate;
  29. double countyTax = purchase * countyTaxRate;
  30. double totalTax = stateTax + countyTax;
  31. double totalAmount = purchase + totalTax;
  32.  
  33. // Display results
  34. cout << "Purchase amount: $" << purchase << endl;
  35. cout << "State tax: $" << stateTax << endl;
  36. cout << "County tax: $" << countyTax << endl;
  37. cout << "Total sales tax: $" << totalTax << endl;
  38. cout << "Total amount with tax: $" << totalAmount << endl;
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
Purchase amount: $52
State tax: $2.08
County tax: $1.04
Total sales tax: $3.12
Total amount with tax: $55.12