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
Cerrena [4.2K]
3 years ago
6

Design the below using an array// Sunrise Freight charges standard// per-pound shipping prices to the five states they serve// –

- IL IN OH MI WI// -- 0.60 0.55 0.70 0.65 0.67// Modify this program to reduce its size// by using arraysstartDeclarationsstring statenum poundsstring foundItstring BAD_STATE_MSG = "Sorry, we do not ship to "string FINISH = "XXX"getReady()while state <> FINISHfindPrice()endwhilefinishUp()stopgetReady()output "Enter state or ", FINISH, " to quit"input statereturnfindPrice()foundIt = "N"if state = "IL" thenprice = 0.60foundIt = "Y"elseif state = "IN" thenprice = 0.55foundIt = "Y"elseif state = "MI" thenprice = 0.70foundIt = "Y"elseif state = "OH" thenprice = 0.65foundIt = "Y"elseif state = "WI" thenprice = 0.67foundIt = "Y"endifendifendifendifif foundIt = "N" thenoutput BAD_STATE_MSG, stateelseoutput "Enter pounds "input poundsoutput "Cost per pound to ship to ", state, " is ", priceoutput "Total cost is ", price * poundsendifoutput "Enter next state or ", FINISH, " to quit"input statereturnfinishUp()output "End of job"return
Computers and Technology
1 answer:
Nataliya [291]3 years ago
3 0

Answer:

string state

num pounds

num SIZE = 5

string STATES[SIZE] = [“IL”, “IN”, “OH”, “MI”, “WI”]

num PRICES[SIZE] = [0.60, 0.55, 0.70, 0.65, 0.67]

num temp

string foundIt

string BAD_STATE_MSG = "Sorry, we do not ship to ”

string FINISH = “XXX”

getReady()

while state <> FINISH

findPrice()

endwhile

finishUp()

stop

getReady()

output "Enter state or ", FINISH, " to quit"

input state

return

findPrice()

foundIt = "N"

temp = 0

index = 0

while temp < SIZE

if state = STATES[temp] then

foundIt = "Y"

index = temp

temp = SIZE

endif

temp = temp + 1

endwhile

if foundIt = "N" then

output BAD_STATE_MSG, state

else

price = PRICES[index]

output “Enter pounds “

input pounds

output “Cost per pound to ship to ”, state, “ is ”, price

output “Total cost is ”, price * pounds

endif

output "Enter next state or ", FINISH, " to quit"

input state

return

finishUp()

output "End of job"

return

Explanation:

  • Initialize the required variables and arrays.
  • Inside the while loop, call the findPrice() method.
  • Run a while loop until temp is less than Size.
  • If state is found then set the value of foundIt variable to "Y" and assign the value of temp to index variable.
  • Finally call the finishUp method and return.

You might be interested in
Which of the following describes colors, spacing, borders, and other effects that change the appearance of a table?
lisabon 2012 [21]
It is the table style that describes colors and spacing borders and other effects that change the appearance of the table
5 0
3 years ago
Which type of software-generated problems can indicate that a software bug is causing a memory error?
Katena32 [7]
The type of software-generated problems that can indicate that a software bug is causing a memory error are page fault, exception error and general-protection fault. Registry errors show that there are parts of the registry that were written to the faulty parts of the RAM. An erroneous memory count would happen when there is incompatibility in the installation.
3 0
3 years ago
Give a pseudo-code description of the O(n)-time algorithm for computing the power function p(x,n).Also draw the trace of computi
laila [671]

Answer:

p(x,n)

1. if(n==0)    [if power is 0]

2.    then result =1.

3.else

4. {    result=1.

5.      for i=1 to n.

6.          {  result = result * x. }  [each time we multiply x once]

7.       return result.

8.  }

Let's count p(3,3)

3\neq0, so come to else part.

i=1: result = result *3 = 3

i=2: result = result *3 = 9

i=2: result = result *3 = 27

Explanation:

here the for loop at step 4 takes O(n) time and other steps take constant time. So overall time complexity = O(n)

6 0
3 years ago
Write a Python program to solve the problem described above. Define a function satisfactory_meal(Meal) which takes a single para
kompoz [17]

def dx(fn, x, delta=0.001):

   return (fn(x+delta) - fn(x))/delta

def solve(fn, value, x=0.5, maxtries=1000, maxerr=0.00001):

   for tries in xrange(maxtries):

       err = fn(x) - value

       if abs(err) < maxerr:

           return x

       slope = dx(fn, x)

       x -= err/slope

   raise ValueError('no solution found')

3 0
2 years ago
When pasting a circle drawn by the presentation software drawing tool into a spreadsheet, that circle will go into the selected
ivann1987 [24]
The answer is ............................ False
6 0
3 years ago
Read 2 more answers
Other questions:
  • Which program can damage your computer
    13·2 answers
  • The inventory tracking system shows that 12 laptop were on hand before a customer brings two laptops to the register for purchas
    9·1 answer
  • If a computer is capable only of manipulating and storing integers, what di themselves? How are these difficulties overcome
    13·1 answer
  • Which of the following can be considered beta testing? A programmer at Linus Systems checks the integration of multiple modules
    14·1 answer
  • Supports traditional transactional processing for day-to-day front-office operations or systems that deal directly with the cust
    11·1 answer
  • According to chronology, arrange the steps that you need to take during the installation of a ram stick?
    13·1 answer
  • No production Web application, whether it resides inside or outside of the firewall, should be implemented without:
    6·1 answer
  • What is the build in libary function to compare two strings?​
    15·1 answer
  • Is it okay for potential employers to search your social media for use in determining if you are a fit for the position?
    15·1 answer
  • 1.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!