Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE HELP! JAVA A shipping company uses the following function to calculate the cost in dollars of shipping based on the weight of the package

PLEASE HELP! JAVA

A shipping company uses the following function to calculate the cost in dollars of shipping based on the weight of the package (in pounds) Note that if you already checked and the weight is NOT less than or equal 1 pound (say its 1.5 pounds), that means its automatically greater than one pound so you dont have to check in the next if statement if its greater than 1 pound, since it must be otherwise you would not be testing if its less than or equal to 3 pounds. Just check that its less than or equal to 3 pounds. No AND or OR conditions are required (which we havent learned yet).

Weight Cost
Less than or equal to 0 pounds display a message Invalid input
Less than or equal to 1 pound $3.50
Greater than 1 but less than or equal to 3 pounds $5.50
Greater than 3 but less than or equal to 10 pounds $8.50
Greater than 10 bit less than or equal to 20 pounds $10.50
If the weight is greater than 20 pounds, display a message The package cannot be shipped

Write a program that prompts the user to enter the weight of the package and displays the shipping cost or an appropriate error message. Test your program with the following inputs: -10

0

0.5

1

7.25

20

21

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions