Question

A Shipping company uses the following function to display the flat rate cost (in dollars) of...

A Shipping company uses the following function to display the flat rate cost (in dollars) of shipping based on the weight of a package (in pounds). Cost function c(w) Cost Weight $3.5 0 < w < = 1 $5.5 1 < w <= 3 $8.5 3 < w <= 10 $10.5 10 < w <= 20 Can’t be shipped 20 < w Write an Assembly program that prompts the user to enter the weight of the package and display the shipping cost. If the weight is greater than 20 pounds, display the following message, “the package cannot be shipped.”

use Pep9 assembly language only

language Design: Code: Output

Homework Answers

Answer #1
import java.util.Scanner; public class ProgrammingEx3_18 { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter the weight of the package in pound:"); double w = input.nextDouble(); double cost = 0; if (w > 0 && w <= 1) { cost = 3.5; } else if (w > 1 && w <= 3) { cost = 5.5; } else if (w > 3 && w <= 10) { cost = 8.5; } else if (w > 10 && w <= 20) { cost = 10.5; } if (cost == 0) { System.out.print("the package cannot be shipped."); System.exit(0); } System.out.print("The cost of shipping is " + cost); } }
Know the answer?
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
Similar Questions
C++ :The Fast Freight Company charges the following rates: Weight of Package (in Kilograms) Rate per...
C++ :The Fast Freight Company charges the following rates: Weight of Package (in Kilograms) Rate per 500 Miles shipped 2 Kg or less $1.10 Over 2 Kg but not more than 6 Kg $2.35 Over 6 Kg but not more than 10 Kg $3.70 Over 10 Kg but not more than 20 Kg $4.80 Write a program that asks for the weight of the package and the distance it is to be shipped, and then display the charges. Input Validation:...
A shipping company offers the following plan: for any package to be shipped, they charge a...
A shipping company offers the following plan: for any package to be shipped, they charge a fixed $2.00 fee in addition to a cost of $2.50 per pound and suppose that the company has a loss of $1.50 per pound. If the weight (rounded up) in pounds of the shipment is a random variable with the following probability mass function P(X = k) = 15 k=1,2,3,4,5 a) Define Y = Profit. Describe the probability distribution of Y. b) Find the...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT