108k views
1 vote
Write a C++ program that will compute the total sales tax on a $95 purchase. Assume the state sales tax is 6% and the county sales tax is 2%. You only have to output the total sales tax. You should not output any text nor should to output the $. Make sure you end your output with the endl or "/n" new line character. You must calculate the total taxes in the program, and then output them. Do not calculate them outside of the program. Your program should assign the value of 95 to a variable, you should not read in the value from cin. If you try to read in the value from cin your program will not pass the test in Submit mode. Create variables for the purchase price, state sales tax rate, county sales tax rate, and the total sales tax that you will be calculating. Give these variables meaningful names. The following are NOT meaningful variable names - p, st, co, ts. Examples of a meaningful variable names would be purchasePrice.

User Lisa Anne
by
4.9k points

1 Answer

1 vote

Answer:

#include <iostream>

using namespace std;

int main()

{

double purchasePrice = 95;

double stateSalesTaxRate = 0.06;

double countySalesTaxRate = 0.02;

double totalSalesTax;

totalSalesTax = (purchasePrice * stateSalesTaxRate) + (purchasePrice * countySalesTaxRate);

cout << totalSalesTax << endl;

return 0;

}

Step-by-step explanation:

Initialize the purchasePrice, stateSalesTaxRate, and countySalesTaxRate and declare the totalSalesTax

Calculate the totalSalesTax; multiply the price by state tax rate to find state tax, multiply the price by county tax rate to find county tax, and sum these values

Print the totalSalesTax

User Rithiur
by
4.8k points