fork download
  1. //Julio Ramirez CSC5 Chapter 2, P. 81, #3
  2.  
  3. /*******************************************************************************
  4.  * Sales Tax
  5.  * _____________________________________________________________________________
  6.  * This program computes the total sales tax on an puchase based on the county
  7.  * sales tax and state stales tax.
  8.  *
  9.  * Computation is based on the Formula:
  10.  * Pre Tax Cost = Puchase Cost / (1 + County Sales tax + State Sales Tax)
  11.  * and
  12.  * Total Tax = Puchase Cost - Pre Tax Cost
  13.  * _____________________________________________________________________________
  14.  * INPUT
  15.  * cost : Puchase cost
  16.  * stateTax : State sales tax
  17.  * countyTax : County slaes tax
  18.  *
  19.  * OUTPUT
  20.  * preTax : Pre tax cost
  21.  * totalTax : Total sales tax
  22.  *
  23.  ******************************************************************************/
  24. #include <iostream>
  25. using namespace std;
  26.  
  27. int main()
  28. {
  29. float cost; //Input - Puchase cost
  30. float stateTax; //Input - State Sales Tax
  31. float countyTax; //Input - County Sales Tax
  32. float preTax; //Output - Pre tax cost
  33. float totalTax; //Output - Total Sales Tax
  34.  
  35. // Initialize Program Variables
  36. cost = 52;
  37. stateTax = .04;
  38. countyTax = .02;
  39.  
  40. // Compute Pre Tax Cost
  41. preTax = cost / (1+ stateTax + countyTax);
  42.  
  43. // Compute Total Tax
  44. totalTax = cost - preTax;
  45.  
  46. // Output Results
  47. cout << "The total tax on a $" << cost << " purchase is $" << totalTax;
  48. return 0;
  49. }
  50.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
The total tax on a $52 purchase is $2.94339