A retail company must file a monthly sales tax report listing the sales for the month and the amount of sales tax collected. Write a program that asks for the month, the year, and the total amount collected at the cash register (that is, sales plus sales tax). Assume the state sales tax is 4 percent and the county sales tax is 2 percent. Those are percentages of pre-tax prices (S, or "product sales" below).
If the total amount collected is known and the total sales tax is 6 percent, the amount of product sales may be calculated as:
S = T/1.06
S is the product sales and T is the total income (product sales plus sales tax). 1.06 comes from the total of 6% sales tax.
The program should save a text file containing a report on the month's sales and tax, as shown below.
Here is a sample of how the program should behave. It displays the name of the text file (SalesTaxData.txt), so the user knows where to find the report. To actually see the report, the user has to look at that file. (Remember the Unix command "cat" displays the contents of a text file.)
bash-2.04$ a.out Please enter the month for this report: February Please enter the year for this report: 2005 Please enter the total income for this month: 15000.25 Sales Tax Report Saved to file: SalesTaxData.txt bash-2.04$ cat SalesTaxData.txt Month: February 2005 ----------------------- Total Collected: $ 15000.25 Sales: $ 14151.18 County Sales Tax: $ 283.02 State Sales Tax: $ 566.05 Total Sales Tax: $ 849.07 ----------------------- bash-2.04$ a.out Please enter the month for this report: October Please enter the year for this report: 2004 Please enter the total income for this month: 26572.89 Sales Tax Report Saved to file: SalesTaxData.txt bash-2.04$ cat SalesTaxData.txt Month: October 2004 ----------------------- Total Collected: $ 26572.89 Sales: $ 25068.76 County Sales Tax: $ 501.38 State Sales Tax: $ 1002.75 Total Sales Tax: $ 1504.13 -----------------------