1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
sweet [91]
3 years ago
12

// This program accepts any number of purchase prices// and computes state sales tax as 6% of the value// and city sales tax as

2% of the value// Modify the program so that the user enters// the two tax rates// at the start of the programstartDeclarationsnum pricenum STATE_TAX_RATE = 0.06num CITY_TAX_RATE = 0.02num totalTaxnum totalstartUp()while price not equal to 0mainLoop()endwhilefinishUp()stopstartUp()output "Enter a price or 0 to quit"input pricereturnmainLoop()totalTax = price * STATE_TAX_RATE + price * CITY_TAX_RATEtotal = price + totalTaxoutput "Price is " , price, " and total tax is ", totalTaxoutput "Total is ", totaloutput "Enter a price or 0 to quit"input pricereturnfinishUp()output "End of program"return
Computers and Technology
2 answers:
elixir [45]3 years ago
7 0

Answer:

Hi there! This is a good question that tests the basics of loops and user input as well as constants and methods. For the sake of simplicity, I have implemented the program in Python. Please find the implementation of this answer below.

Explanation:

Simply save the below code in a file called sales_tax_value.py and run it with python 2.0. If using Python 3.0 + then you'll need to change the line:

"price = raw_input("Enter a price or 0 to quit: ");"

to

"price = input("Enter a price or 0 to quit: ");

sales_tax_value.py

def calculate_total(price):

 totalTax = price * STATE_TAX_RATE + price * CITY_TAX_RATE;

 total = price + totalTax;

 return total;

pricenum = -1;

price = pricenum;

STATE_TAX_RATE = 0.06;

CITY_TAX_RATE = 0.02;

while price != 0:

 price = raw_input("Enter a price or 0 to quit: ");

 try:

   price = int(price);

   print(calculate_total(price));

 except ValueError:

   print("Invalid input!");

   price = -1;

chubhunter [2.5K]3 years ago
7 0

Question:

// This program accepts any number of purchase prices

// and computes state sales tax as 6% of the value

// and city sales tax as 2% of the value

//Modify the program so that the user enters

// the two tax rates

// at the start of the program

start

Declarations

num price

num STATE_TAX_RATE = 0.06

num CITY_TAX_RATE = 0.02

num totalTax

num total

startUp()

while price not equal to 0

mainLoop()

endwhile

finishUp()

stopstartUp()

output "Enter a price or 0 to quit"

input price

returnmain

Loop()

totalTax = price * STATE_TAX_RATE + price * CITY_TAX_RATE

total = price + totalTax

output "Price is " , price, " and total tax is ", totalTaxoutput "Total is ", total

output "Enter a price or 0 to quit"

input price

return finishUp()

output "End of program"

return

Answer

Modified Program below

// This program accepts any number of purchase prices

// and computes state sales tax as 6% of the value

// and city sales tax as 2% of the value

//Modify the program so that the user enters

// the two tax rates

// at the start of the program

start

Declarations

num price

num STATE_TAX_RATE

num CITY_TAX_RATE

num totalTax

num total

input STATE_TAX_RATE

input CITY_TAX_RATE

startUp()

while price not equal to 0

mainLoop()

endwhile

finishUp()

stopstartUp()

output "Enter a price or 0 to quit"

input price

returnmain

Loop()

totalTax = price * STATE_TAX_RATE + price * CITY_TAX_RATE

total = price + totalTax

output "Price is " , price, " and total tax is ", totalTaxoutput "Total is ", total

output "Enter a price or 0 to quit"

input price

return finishUp()

output "End of program"

return

You might be interested in
What is computer with figure​
GenaCL600 [577]

Answer:

A computer is an electronic device that accept raw data and instructions and process it to give meaningful results.

5 0
3 years ago
What is the purpose of the domain name? The domain name is an example of a service provider. The domain name .gov.nz is an examp
malfutka [58]

.gov.nz is for New Zealand

6 0
3 years ago
Read 2 more answers
John is researching the job of a quality control inspector. He thinks it would be fun to monitor the production process and test
Evgesh-ka [11]
Near-perfect eyesight and detail perception would be good traits to have. 
6 0
3 years ago
Read 2 more answers
Alice sends a message to Bob in a manner such that Bob is the only person who can tell what the real message is. Which security
cupoosta [38]

Answer:

confidentiality

Explanation:

Alice sends a message to Bob in a manner such that Bob is the only person who can tell what the real message is. Which security concept is this an example of

3 0
3 years ago
A window frame will expand to fill the entire desktop when you
natima [27]
A. Sometimes it is marked by outwards pointing arrows (<= =>) with the reverse (collapsing so as to not take up the whole screen) being in the same spot, marked by inwards arrows (=> <=)
8 0
3 years ago
Other questions:
  • Is it possible to do calculations with text data in Ms Excel
    9·2 answers
  • Your friend sends you a computer game. after installing the game on your computer, you realize that it plays very slowly. you kn
    14·1 answer
  • In a linux script, the line ____ is important because it identifies the file as a script.
    5·1 answer
  • 11 of the 25 people on the bus get off at the first stop. What percent best represents the portion of the bus that got off on th
    7·1 answer
  • To read visual and audio text means
    11·1 answer
  • Which statement about images is correct? A) A virtual image cannot be formed on a screen. B) A virtual image cannot be viewed by
    12·1 answer
  • Hello users !
    10·2 answers
  • Examples of system software include operating systems like macos, Linux, Android and
    10·2 answers
  • it refers to the ability of different parts of a computer to work together as one. please answer this​
    6·1 answer
  • What is the console.log function for?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!