Programming Challenge Chapter 3 – Q #12 Monthly Sales Tax – Tony Gaddis – Starting Out With C++

Programming Challenge Chapter 3 – Q #12 Monthly Sales Tax – Tony Gaddis – Starting Out With C++


Problem: -

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. 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). The program should display a report similar to
                                   Month  : October 
                                   --------------------
                                Total Collected: $ 26572.89 
                                                Sales: $ 25068.76 
                            County Sales Tax: $     501.38
                                State Sales Tax: $   1002.75
                                Total Sales Tax: $   1504.13

Solution: -

#include <iostream>

#include <iomanip>

#include <string>

using namespace std;

int main()

{

      float const STATE_TAX = 0.04,

            COUNTRY_TAX = 0.02,

            TOTAL_SALE_TAX = 0.06;

      string month;

      int year;

      float T;

   float S = 0.0, state_tax = 0.0, country_tax = 0.0, total_tax = 0.0;

      cout << "Enter Month Name (i.e March):    ";

      cin >> month;

      cout << "Enter Year:    ";

      cin >> year;

      cout << "Enter Total Collected Ammount:  $";

      cin >> T;

 

      S = T / 1.06;                  

      state_tax = S * STATE_TAX;

      country_tax = S * COUNTRY_TAX;

      total_tax = S * TOTAL_SALE_TAX;     

      cout << setprecision(2) << showpoint << fixed;

      cout << "\nMonth: " << month << "\n-----------------------\n";

     cout << "Total Collected Ammount:   $" << setw(10) << T << endl;

     cout << "Sales :                    $" << setw(10) << S << endl;

     cout << "State Tax:                 $" << setw(10) << state_tax << endl;

      cout << "Country Tax:              $" << setw(10) << country_tax << endl;

      cout << "Total Sales Tax:           $" << setw(10) << total_tax << endl;

 

      return 0;

}


This is the solution of this question




OUTPUT OF THIS QUESTION 

Input is highlighted with yellow color.


Explanation of this Solution

  1. Declare three float constants and initialize given values.
  2. Declare a string variable for input.
  3. Declare a int variable for input.
  4. Declare another one float variable for calculation.
  5. Take input one by one from the user by using cin.
  6. Calculate the values by using given values and values.
  7.  In last, display output on the screen in a pattren.
  8. Return 0 to the main function.

Also, I attach CPP file of this problem. You can download this file

Click Here to Download This File


Post a Comment

0 Comments