Question

Write a program that will compute the total sales tax on a $95 purchase. Assume the...

Write a program that will compute the total sales tax on a $95 purchase.
Assume the state sales tax is 4 percent and the county sales tax is 2 percent
... and then display the amounts for the total sales tax, state sales tax, and
county sales tax.

the pseudo code is:

since the tax rates do not vary, we will declare them as constants:
const double STATE_SALES_TAX_RATE = 0.04 //copy initialization
const double CNTY_SALES_TAX_RATE(0.02) //direct initialization

declare variable to hold the purchase amount:
double purchase

store amount of purchase:
purchase = 95.00

declare three variables to store the sales tax values
double stateSalesTax, cntySalesTax, totalSalesTax

compute amounts for sales taxes and store in memory:
stateSalesTax = STATE_SALES_TAX_RATE * purchase
cntySalesTax = CNTY_SALES_TAX_RATE * purchase
totalSalesTax = stateSalesTax + cntySalesTax

display results ...

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>

using namespace std;

int main()
{
  
const double STATE_SALES_TAX_RATE = 0.04; //copy initialization
const double CNTY_SALES_TAX_RATE(0.02); //direct initialization

//declare variable to hold the purchase amount:
double purchase;

//store amount of purchase:
purchase = 95.00;

//declare three variables to store the sales tax values
double stateSalesTax, cntySalesTax, totalSalesTax;

//compute amounts for sales taxes and store in memory:
stateSalesTax = STATE_SALES_TAX_RATE * purchase;
cntySalesTax = CNTY_SALES_TAX_RATE * purchase;
totalSalesTax = stateSalesTax + cntySalesTax;

//displaying the result
cout<<"State Sales Tax is : "<<stateSalesTax<<", Country Sales Tax is : "<<cntySalesTax<<" and Total Sales Tax is : "<<totalSalesTax<<"\n";
return 0;
}

written the code in cpp, please let me know if anything is required.

Add a comment
Know the answer?
Add Answer to:
Write a program that will compute the total sales tax on a $95 purchase. Assume the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Q2.     Write a program that will compute the total sales tax on a $45 purchase. Assume...

    Q2.     Write a program that will compute the total sales tax on a $45 purchase. Assume that the state sales tax is 4% and county sales tax is 2%. Declare a variable called price , of datatype double Ask the user to enter a price and the user inputs in the purchase price. Use setprecision(2) like Q1. in C++

  • In Java, write a program that will ask the user to enter the amount of a...

    In Java, write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of the purchase, the state sales tax, the county sales tax, the total sales tax, and the total of the sale (which is the sum of the amount of purchase...

  • This is JAVA. Must write a short description of this program, usually a sentence or two...

    This is JAVA. Must write a short description of this program, usually a sentence or two will be sufficient. All the classes, methods and data fields should be clearly documented (commented). Write a program that will ask the user to enter the amount of a purchase. The program should then compute the state and county sales tax. Assume the state sales tax is 4 percent and the county sales tax is 2 percent. The program should display the amount of...

  • C++ chapter 2 programming challenge #3 Write a program that will compute the total sales tax...

    C++ chapter 2 programming challenge #3 Write a program that will compute the total sales tax on a $95 purchase. Assume the state sales tax is 4 percent, and the county sales tax is 2 percent.

  • Property Tax Program -Must use C programming I attempted this program but couldn't figure what I...

    Property Tax Program -Must use C programming I attempted this program but couldn't figure what I did wrong ;( Property Tax Program Complete the following program: A retail company must file a monthly sales tax report listing the total sales for the month and the amount of state and county sales tax collected. The state sales tax rate is (4 percent and the county sales tax rate is 2 percent. Write a program that asks the user to enter the...

  • Can you solve this proble by using C# application? C# is one of programming languages supported...

    Can you solve this proble by using C# application? C# is one of programming languages supported by Visual Studio 2015. It combines the features of Java and C ++ and is suitbale for rapid application development. A retail company must file a monthly sales tax report listing the total sales for the month, and the amount of state and county sales tax collected. The state sales tax rate is 4% and the county sales tax rate is 2%. Create an...

  • Write a program that will compute the user annual salary. Prompt the user the enter (1)...

    Write a program that will compute the user annual salary. Prompt the user the enter (1) the weekly salary. Store the information in a double variable. Prompt the user to enter the number of weeks worked in a year. Use an int variable for that. Write code that will compute the user's Annual salary. Gross salary is salary before any deductions are taken. Update the code and prompt the user to enter the federal tax rate and the state's tax...

  • In this project you will write a C++ program that simulates the purchase of a single...

    In this project you will write a C++ program that simulates the purchase of a single item in an online store. What to do Write a C++ program that: 1. Prints out a welcome message. 2. Prompts the user for the following information: (a) Their first name (example: Roger) (b) Their last name (example: Waters) (c) The name of the product (example: Brick) (d) The unit price of the product (example: 1.99) (e) The quantity to buy (example: 200) (f)...

  • The XYZ Company needs you to write a program that will allow them to enter the...

    The XYZ Company needs you to write a program that will allow them to enter the weekly sales for a salesperson and then the program will calculate things such as most sales (and what day on which they happened), least sales (and day on which they happened), total sales, and daily average. The program will need to do the following: • Validate the user input to ensure that it is not less than 0.0 (0.0 will be acceptable if there...

  • Write a program in C++ that simulates a soft drink machine. The program will need several...

    Write a program in C++ that simulates a soft drink machine. The program will need several classes: DrinkItem, DrinkMachine and Receipt. For each of the classes you must create the constructors and member functions required below. You can, optionally, add additional private member functions that can be used for doing implementation work within the class. DrinkItem class The DrinkItem class will contains the following private data members: name: Drink name (type of drink – read in from a file). Type...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT