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
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); } }
Get Answers For Free
Most questions answered within 1 hours.