fork(1) download
  1. //Grace Fermelia CS1A Chapter 2, P. 81, #3
  2. //
  3. /**************************************************************
  4. *
  5. * COMPUTE SALES TAX
  6. * ____________________________________________________________
  7. * This program computes total sales tax for a purchase based on purchase total
  8. * and precents for sales taxes and displays the result.
  9. *
  10. * Computation is based on the formulas:
  11. * state_Tax = state_Percent x purchase
  12. * county_Tax = county_Percent x purchase
  13. * sales_Tax = state_Tax + county_Tax
  14. * ____________________________________________________________
  15. * INPUT
  16. * purchase : Total amount spent (USD) not including tax
  17. * state_Percent : Percent of state tax as decimal
  18. * county_Percent : Percent of county tax as decimal
  19. *
  20. * OUTPUT
  21. * state_Tax : amount (USD) of state tax
  22. * county_Tax : amount (USD) of county tax
  23. * sales_Tax : Total sales Tax (USD)
  24. *
  25. **************************************************************/
  26. #include <iostream>
  27. #include <iomanip>
  28. using namespace std;
  29. int main ()
  30. {
  31. double purchase; //INPUT -Total amount spent (USD) not including tax
  32. double state_Tax; //OUTPUT -amount (USD) of state tax
  33. double state_Percent; //INPUT -Percent of state tax as decimal
  34. double county_Tax; //OUTPUT -amount (USD) of county tax
  35. double county_Percent;//INPUT -Percent of county tax as decimal
  36. double sales_Tax; //OUTPUT -total sales Tax (USD)
  37.  
  38. // Initialize Program Variables
  39. purchase = 52;
  40. state_Percent = .04;
  41. county_Percent = .02;
  42.  
  43. // Compute state_Tax
  44. state_Tax = state_Percent *purchase;
  45. // Compute county_Tax
  46. county_Tax = county_Percent * purchase;
  47. // Compute sales_tax
  48. sales_Tax = state_Tax + county_Tax;
  49.  
  50. // Output Result
  51. cout << "The Sales Tax is $"<< sales_Tax <<endl;
  52. return 0;
  53. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
The Sales Tax is $3.12