fork download
  1. //Natalie Zarate CIS5 Chapter 3, P. 145, #12
  2.  
  3. /*******************************************************************************
  4.  *
  5.  * COUMPUTE SALES TAX
  6.  * _____________________________________________________________________________
  7.  * This program will accept as input the month, year,and amount of sales tax
  8.  * collected and will compute sales, the county and state sales tax, and the
  9.  * total sales tax.
  10.  *
  11.  * Computation is based on the formula:
  12.  *
  13.  * product sales = total income / 1.06
  14.  *
  15.  * And the assumption that the state tax rate = 4%, the county tax rate = 6% and
  16.  * the total amount collected at the cash register = $26572.89
  17.  * _____________________________________________________________________________
  18.  * INPUT
  19.  * month : The month of the year this computation is based in
  20.  * year : The year this compuation is based in
  21.  * totalAmnt : The total amount collected at the cash register
  22.  * (sales + sales tax)
  23.  * stateTax : Tax rate levied by the sate
  24.  * countyTax : Tax rate levied by the county
  25.  *
  26.  * OUTPUT
  27.  * salesT : totalAmnt / 1.06
  28.  * csalesT : total sales tax collected by county
  29.  * sSalesT : total sales tax collected by state
  30.  * totalsT : total sales tax collected
  31.  *
  32.  ******************************************************************************/
  33. #include <iostream>
  34. #include <iomanip>
  35. #include <string>
  36. using namespace std;
  37.  
  38. int main()
  39. {
  40. string month; // INPUT - The month of the year this
  41. // computation is based in
  42. int year; // INPUT - The year this compuation is based in
  43. float totalAmnt = 26572.89; // INPUT - The total amount collected at the
  44. // cash register (sales + sales tax)
  45. float stateTax = 0.04; // INPUT - Tax rate levied by the state
  46. float countyTax = 0.02; // INPUT - Tax rate levied by the county
  47. float salesT; // OUTPUT - totalAmnt / 1.06
  48. float csalesT; // OUTPUT - sales tax collected by county
  49. float sSalesT; // OUTPUT - sales tax collected by state
  50. float totalsT; // OUTPUT - total sales tax collected
  51.  
  52. // Prompt user for year and display
  53. cout << "Year: ";
  54. cin >> year;
  55. cout << year <<endl;
  56.  
  57. // Prompt user for month and display
  58. cout << "Month: ";
  59. cin >> month;
  60. cout << month <<endl;
  61.  
  62. // Seperate from tax information
  63. cout << "--------------------" << endl;
  64.  
  65. // Display total collected
  66. cout << "Total Collected: " << setw(6) << "$ ";
  67. cout << setprecision(2) << fixed << totalAmnt << endl;
  68.  
  69. // Compute and display total sales
  70. salesT = totalAmnt / 1.06;
  71. cout << "Sales: " << setw(16) << "$ " << setw(8) << salesT << endl;
  72.  
  73. // Compute and display sales tax collected by county
  74. csalesT = salesT * countyTax;
  75. cout << "County Sales Tax: " << setw(5) << "$ ";
  76. cout << setw(8) << csalesT << endl;
  77.  
  78. // Compute and display sales tax collected by state
  79. sSalesT = salesT * stateTax;
  80. cout << "State Sales Tax: " << setw(6) << "$ ";
  81. cout << setw(8) << sSalesT << endl;
  82.  
  83. // Compute and display total sales tax
  84. totalsT = csalesT + sSalesT;
  85. cout << "Total Sales Tax: " << setw(6) << "$ ";
  86. cout << setw(8) << totalsT;
  87.  
  88.  
  89. return 0;
  90. }
Success #stdin #stdout 0s 5276KB
stdin
2024
October
stdout
Year: 2024
Month: October
--------------------
Total Collected:     $ 26572.89
Sales:               $ 25068.77
County Sales Tax:    $   501.38
State Sales Tax:     $  1002.75
Total Sales Tax:     $  1504.13