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++
Hi,
As per the requirement, putting below the code of program that will compute total sales tax on purchase value assuming 4% state sales tax and 2% country sales tax. Also setprecision(2) is implemented. As no information is available about Q1, setprecision(2) is implemented as per the standard way.
*********************** Code Begins ********************************
#include <iostream>
#include <iomanip>
using namespace std;
double calculate_total_tax(double price)//Function to calculate
Total Sales Tax
{
double state_sales_tax, country_sales_tax;
double total_sales_tax;
state_sales_tax = (price * 4) / 100; //As State Sales
Tax is 4%
country_sales_tax = (price * 2) / 100; //As Country
Sales Tax is 4%
total_sales_tax = state_sales_tax +
country_sales_tax;
return total_sales_tax;
}
int main()
{
double price;
double total_sales_tax;
cout << "Enter price => $";
cin >> price; //Taking purchase price from
user
total_sales_tax = calculate_total_tax(price);
//Calling calculate_total_tax function
cout << fixed << showpoint;
cout << setprecision(2);
cout << "Total sales tax on $" << price
<< " purchase is $" <<
total_sales_tax;
return 0;
}
*********************** End of Code ********************************
Also as mentioned in question, putting screenshot of output
calculated using $45 as purchase price.
That's all for now.
Open for comments, queries if any.
Thank you.
Q2. Write a program that will compute the total sales tax on a $45 purchase. Assume...
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...
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.
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 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...
java; programing language Write a program to calculate the price of a purchase. It should ask the user to enter the name of the item bought (like sweater, apple, …), number of items bought (4, 5 lbs,…), price per item ($40.50, $1.99 per pound,…), and the sales tax rate (8.35% for example). It should calculate the subtotal (price*number of items), sales tax (subtotal*sales tax), and total price (subtotal+ sales tax). It should print all the information in a receipt form
Answer using C++ Write a program that will calculate the final sales price of a motorcycle; this includes additional optional packages along with sales tax. You may assume that the base? price of the motorcycle is $30,000. First you must ask the user to choose which optional packages they want. The user is only permitted to choose one package. Your program should display a menu of the available packages. The user should enter the package by entering the letter associated...
Help. In language c
View Layout References Mailings Program 1 Write a simple invoice generating program for a pet store as follows: 1- Ask the user for tee tax rate and store it in a float variable. 2- Ask the user for the number of cats being purchased and store the value in an integer variable. 3- Ask the user for the price of one cat and store it in a float variable. 4- Ask the user for the number...
Write a C++ program to compute the total volume of N cones, where N is a number entered by the user. Repeat the request for N until the user enters a positive number. For each cone, ask for the radius and height, compute the volume, and add that volume to the total. Each time you ask the user to enter either the height or the radius, if the user does not enter a positive number, display an error message and...
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...
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...