fork download
  1. // Marvyn De La Torre CS1A Chapter 2, P. 81, #3
  2.  
  3. /****************************************************************
  4. * Compute Total Sales Tax
  5. * --------------------------------------------------------------
  6.  * This program calculates the state tax, county tax, and total
  7.  * sales tax on a $52.00 purchase.
  8.  * --------------------------------------------------------------
  9.  * INPUT
  10.  * purchaseAmount : Cost of the purchase
  11.  * stateTaxRate : State sales-tax rate
  12.  * countyTaxRate : County sales-tax rate
  13.  *
  14.  * OUTPUT
  15.  * totalSalesTax : Combined state and county sales tax
  16.  ****************************************************************/
  17.  
  18. #include <iostream>
  19. using namespace std;
  20.  
  21. int main()
  22. {
  23. float purchasePrice; // INPUT - Cost of purchase
  24. float stateTax; // OUTPUT - State sales tax
  25. float countyTax; // OUTPUT - County sales tax
  26. float totalSalesTax; // OUTPUT - Total sales tax
  27.  
  28. // Set the purchase price
  29. purchasePrice = 52.00;
  30.  
  31. // Compute state and county tax
  32. stateTax = purchasePrice * 0.04;
  33. countyTax = purchasePrice * 0.02;
  34.  
  35. // Compute total sales tax
  36. totalSalesTax = stateTax + countyTax;
  37.  
  38. // Display result
  39. cout << "The total sales tax is $" << totalSalesTax << endl;
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0s 5316KB
stdin
Standard input is empty
stdout
The total sales tax is $3.12