fork download
  1. //Jacklyn Isordia CSC5 Chapter 2, P. 81, #03
  2. //
  3. /**************************************************************
  4.  *
  5.  * Calculating the total cost with sales tax
  6.  * ____________________________________________________________
  7.  * This program computes the total sales tax on a $52 purchase.
  8.  * The program calculates the state sales tax and the county
  9.  * sales tax, then finds the toatl sales tax amount.
  10.  *
  11.  * Computation is based on the formula:
  12.  * State Tax = Purchase Amount x State Tax Rate
  13.  * County Tax = Purchase Amount x County Tax Rate
  14.  * Total Tax = State Tax + County Tax
  15.  * ____________________________________________________________
  16.  * INPUT
  17.  * purchaseAmount : cost of the purchase ($52)
  18.  * stateTaxRate : state sales tax rate (4%)
  19.  * countyTaxRate : county sales tax rate (2%)
  20.  *
  21.  * OUTPUT
  22.  * stateTax : amount of state tax
  23.  * countyTax : amount of county tax
  24.  * totalTax : total sales tax
  25.  *
  26.  **************************************************************/
  27. #include <iostream>
  28. using namespace std;
  29. int main ()
  30. {
  31. float purchaseAmount;
  32. float stateTaxRate;
  33. float countyTaxRate;
  34. float stateTax;
  35. float countyTax;
  36. float totalTax;
  37. //
  38. // Initialize Program Variables
  39. purchaseAmount = 52;
  40. stateTaxRate = 0.04;
  41. countyTaxRate = 0.02;
  42. //
  43. // Compute Total
  44. stateTax = purchaseAmount * stateTaxRate;
  45. countyTax = purchaseAmount * countyTaxRate;
  46. totalTax = stateTax + countyTax;
  47. //
  48. // Output Result
  49. cout << "State Tax: " << stateTax << endl;
  50. cout << "County Tax: " << countyTax << endl;
  51. cout << "Total Sales Tax: " << totalTax << endl;
  52.  
  53. return 0;
  54. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
State Tax: 2.08
County Tax: 1.04
Total Sales Tax: 3.12