fork download
  1. //Xinnuo Wang CS1A chapter 3 , P.145, #12
  2. //
  3. /*******************************************************************************
  4. *
  5. * File Monthly Sales Tax Report
  6. *-------------------------------------------------------------------------------
  7. * This program asks to file a monthly sales tax report listing the sales for
  8. * the month and the amount of sales tax collected
  9. *
  10. * computation is based on the formula:
  11. * Sales = Total/ total sales taxes
  12. * County sales tax = total * 4% of county sales tax
  13. * State sales tax = total * 2% of state sales tax
  14. *-------------------------------------------------------------------------------
  15. * INPUT
  16. * total : The total amount collected at the cash register
  17. * month : The report for this month
  18. * year : The report for this year
  19. * taxes : The total taxes
  20. * OUTPUT
  21. * sales : The real sales out of taxes
  22. * countySalesTax: The amount of couty slaes tax
  23. * stateSalesTax : The amount of state slaes tax
  24. * taxes : The total taxes
  25. *******************************************************************************/
  26. #include <iostream>
  27. #include <iomanip>
  28. #include <string>
  29. using namespace std;
  30.  
  31. int main()
  32. {
  33. double total; //INPUT - The total amount collected at the cash register
  34. string month; //INPUT - The report for this month
  35. int year; //INPUT - The report for this year
  36. double taxes; //INPUT - The total taxes
  37. double sales; //OUTPUT - The real sales out of taxes
  38. double countySalesTax; //OUTPUT - The amount of couty slaes tax
  39. double stateSalesTax; //OUTPUT - The amount of state slaes tax
  40. //
  41. //Input Data
  42. cout << "Enter the month" << endl;
  43. cin >> month;
  44. cout << "Enter the year" << endl;
  45. cin >> year;
  46. cout << "Enter the total amount: $" << endl;
  47. cin >> total;
  48. //
  49. // Compute sales
  50. sales = total / 1.06;
  51. //
  52. // Compute county sales tax
  53. countySalesTax = sales * 0.04;
  54. //
  55. // Compute state sales tax
  56. stateSalesTax = sales * 0.02;
  57. //
  58. // Compute total taxes
  59. taxes = countySalesTax + stateSalesTax;
  60. //
  61. // Output Result
  62. cout <<"Month: "<<month<<endl;
  63. cout <<"--------------------"<<endl;
  64. cout <<"Total Collected: $"<<setw(10)<<fixed<<setprecision(2)<<total<<endl;
  65. cout <<"Sales: $"<<setw(10)<<fixed<<setprecision(2)<<sales<<endl;
  66. cout <<"County Sales Tax: $"<<setw(10)<<fixed<<setprecision(2)<<countySalesTax<<endl;
  67. cout <<"State Sales Tax: $"<<setw(10)<<fixed<<setprecision(2)<<stateSalesTax<<endl;
  68. cout <<"Total Sales Tax: $"<<setw(10)<<fixed<<setprecision(2)<<taxes<<endl;
  69. return 0;
  70. }
Success #stdin #stdout 0s 5316KB
stdin
October 2012 34567.00
stdout
Enter the month
Enter the year
Enter the total amount: $
Month: October
--------------------
Total Collected:    $  34567.00
Sales:              $  32610.38
County Sales Tax:   $   1304.42
State Sales Tax:    $    652.21
Total Sales Tax:    $   1956.62