Programming Challenge Chapter 3 – Q #12 Monthly Sales Tax – Tony Gaddis – Starting Out With C++
Problem: -
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
- Declare three float constants and initialize given values.
- Declare a string variable for input.
- Declare a int variable for input.
- Declare another one float variable for calculation.
- Take input one by one from the user by using cin.
- Calculate the values by using given values and values.
- In last, display output on the screen in a pattren.
- Return 0 to the main function.
Also, I attach CPP file of this problem. You can download this file
0 Comments