Question

In: Computer Science

// Sunrise Freight charges standard // per-pound shipping prices to the five states they serve //...

// 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 arrays

start

Declarations

string state

num pounds

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"

if state = "IL" then

price = 0.60

foundIt = "Y"

else

if state = "IN" then

price = 0.55

foundIt = "Y"

else

if state = "MI" then

price = 0.70

foundIt = "Y"

else

if state = "OH" then

price = 0.65

foundIt = "Y"

else

if state = "WI" then

price = 0.67

foundIt = "Y"

endif

endif

endif

endif

if foundIt = "N" then

output BAD_STATE_MSG, state

else

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

Solutions

Expert Solution

// by using arrays
start
Declarations
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.


Related Solutions

Programming 3: Multi-Way Branching Shipping Charges The Fast Freight Shipping Company charges the following rates: Given...
Programming 3: Multi-Way Branching Shipping Charges The Fast Freight Shipping Company charges the following rates: Given the Weight of Package (in Kilograms), use the following Rate ($) per 500 Miles Shipped. 2 kg or less = $1.10 per 500 Miles Shipped Over 2 kg but not more than 6 kg = $2.20 per 500 Miles Shipped Over 6 kg but not more than 10 kg = $3.70 per 500 Miles Shipped Over 10 kg but not more than 20 kg...
The Fast Freight Shipping Company charges the followingrates: Weight of Package(kilograms)         Rate per 500 miles shipped 2...
The Fast Freight Shipping Company charges the followingrates: Weight of Package(kilograms)         Rate per 500 miles shipped 2 kg orless                                                   $1.10 Over 2 kg but not more than6kg                   $2.20 Over 6 kg but not more than 10kg                $3.70 Over 10 kg but not more than 20kg              $4.80 Write a program that asks for the weight of the package andthe distance it is to be shipped, and then displays thecharges. Input Validation: Do not accept values of 0 or less for theweight of the package. Do not...
A manager at Strateline Manufacturing must choose between two shipping alternatives: one-day freight and five-day freight....
A manager at Strateline Manufacturing must choose between two shipping alternatives: one-day freight and five-day freight. Using five-day freight would cost $175 less than using one-day freight. The primary consideration is holding cost, which is $10 per unit a year. One thousand items are to be shipped. Which alternative would you recommend? Explain. Determine which shipping alternative would be most economical to ship 100 boxes of parts when each box has a price of $200 and holding costs are 40...
10)Oxford Co. has a materials standard of 2.1 pounds per unit of output. Each pound has a standard price of $14 per pound.
  10)Oxford Co. has a materials standard of 2.1 pounds per unit of output. Each pound has a standard price of $14 per pound. During February, Oxford Co. paid $57,300 for 4,810 pounds, which were used to produce 2,400 units. What is the direct materials quantity variance? A) $3,220 favorable B)$8,780 favorable C)$9,540 unfavorable D)$1,080 unfavorable 23) Avocado Company has an operating income of $123,900 on revenues of $1,066,000. Average invested assets are $590,000, and Avocado Company has an 13% cost...
The mean cost of a five pound bag of shrimp is 50 dollars with a standard...
The mean cost of a five pound bag of shrimp is 50 dollars with a standard deviation of 8 dollars. If a sample of 56 bags of shrimp is randomly selected, what is the probability that the sample mean would be greater than 49.1 dollars? Round your answer to four decimal places.
Sheffield has a standard of 1.5 pounds of materials per unit, at $6 per pound. In...
Sheffield has a standard of 1.5 pounds of materials per unit, at $6 per pound. In producing 2000 units, Sheffield used 3200 pounds of materials at a total cost of $18720. Sheffield's total variance is $900 F. $1200 U. $480 U. $720 U.
Materials: Standard Qty. Standard Cost     Oats 525 pounds $1.25 per pound     Wheat 450 pounds $1.15 per...
Materials: Standard Qty. Standard Cost     Oats 525 pounds $1.25 per pound     Wheat 450 pounds $1.15 per pound     Barley   85 pounds $1.45 per pound     Malt   65 pounds $2.15 per pound     Honey 25 quarts $1.20 per quart       Water 25 gallons $0.45 per gallon   Time:     Miller 4 1/2 hours $22.75 per hour       Loader 1 1/2 hours $11.50 per hour   Overhead is applied at $5.75 per pound completed. The recipe produced 1,025 pounds of cereal mix. If required, round your answers to the nearest...
Anna owns the Sweet Alps Chocolate store. She charges $10 per pound for her hand made...
Anna owns the Sweet Alps Chocolate store. She charges $10 per pound for her hand made chocolate. You, the economist, have calculated the elasticity of demand for chocolate in her town to be 2.5. If she wants to increase her total revenue, what advice will you give her and why?  USE DIAGRAMS AND ECONOMIC TERMS TO ANSER YOUR QUESTION
Bob owns the Sweet Alps Chocolate store. She charges $10 per pound for her hand made...
Bob owns the Sweet Alps Chocolate store. She charges $10 per pound for her hand made chocolate. You, the economist, have calculated the elasticity of demand for chocolate in her town to be 2.5. If she wants to increase her total revenue, what advice will you give her? A. increase her price, because demand is elastic, increasing the price will increase the total revenue. B. increase her price, because demand is inelastic, increasing the price will increase the total revenue....
On its municipal website, the city of Tulsa states that the rate it charges per 5...
On its municipal website, the city of Tulsa states that the rate it charges per 5 CCF of residential water is $21.62. How do the residential water rates of other U.S. public utilities compare to Tulsa's rate? The data shown below ($) contains the rate per 5 CCF of residential water for 42 randomly selected U.S. cities. 10.68 9.38 12 6.7 12.62 14.73 15.76 10.32 14.7 16.38 17.8 19.38 18.18 13.05 17 17.55 15.84 15 19.11 18.19 15.1 18.62 16.25...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT