I need this in java A6 – Shipping Calculator Assignment Introduction In this part, you will solve a problem...

50.1K

Verified Solution

Question

Programming

I need this in java

A6 – Shipping Calculator

Assignment

Introduction

In this part, you will solve a problem described in English.Although you may discuss ideas with your classmates, etc., everyonemust write and submit their own version of the program. Do NOT useanyone else’s code, as this will result in a zero for you and theother person!

Shipping Calculator

Speedy Shipping Company will ship your package based on theweight and how far you are sending the package, which canbe anywhere in the world. They will only ship small packages up to10 pounds. You need to have a program, which will help youdetermine how much they will charge.

The charges are based on each 500 miles shipped. The mileageshould be in whole numbers. They are not prorated, i.e., 600 milesis the same charge as 900 miles; in other words, 600 and 900 milesis counted as 2 segments of 500 miles each.

Here is the table they gave you:

Package Weight Rate per 500 miles shipped

Charge

2 pounds or less

$1.50

More than 2 but not more than 6

$3.70

More than 6 but not more than 10

$5.25

Your code needs to validate the input completely, e.g., theweight and mile amounts must be positive. If an input is invalid,e.g., the weight is zero or less, you should display anappropriate, professional error message, e.g., Error: Weightmust be greater than zero!, which should be offset andsurrounded by white space, so it stands out, and repeat gettingthat input until valid input is received. Keep in mind, the userwill find it annoying if they must enter both the miles and weightat the same time, and only one of them caused an error, or theymust reenter already valid data. Also, make sure you follow theCode Conventions and good programmingpractices, e.g., appropriately initialize variables to zeros, avoidstacked if or if-else constructs unlessnecessary, don’t use break or continue to get outof a loop, goto, etc.; in other words, you should NOT usestacked if/if-else constructs, break, orcontinue for this assignment.

At this point for the code, you should only solve the problemusing what you learned from modules 1 – 6, i.e., NO arrays,functions other than main(), etc. Only if all the input isvalid, should the program calculate and display one shippingcharge, and pause, but not quit, before proceeding to a newcustomer. Your test cases should test the various possibilities,and the limits of the program, which means, you will need to use anappropriate loop, which will ask if you would like to process thenext customer or not by asking them to enter an appropriate value.Once there are no more customers to process, the program shoulddisplay Good-bye! and end. Remember to solve eachaspect of the program separately, and then, put the partstogether.

Hints: You may need to reset any values afteryou display the answer and before you get the input for the nextcustomer. Big Helpful Hint: For the number ofsegments calculation, you may want to start with integer division,e.g., 1200 miles / 500 miles per segment = 2 segments, and then,expand on that.

You should be able to solve this problem with only one loop.

Sample Run

Enter the number of miles as a whole number:0

        Error: Miles must begreater than zero!

Enter the number of miles as a whole number:1

Enter the weight of the package in pounds:0

        Error: Weight must begreater than zero!

Enter the weight of the package in pounds:1

The cost to ship your package is: $1.50.

Enter 1 to continue or 0 to quit: 1

Enter the number of miles as a whole number:500

Enter the weight of the package in pounds:2

The cost to ship your package is: $1.50.

Enter 1 to continue or 0 to quit: 1

Enter the number of miles as a whole number:500

Enter the weight of the package in pounds:2.5

The cost to ship your package is: $3.70.

Enter 1 to continue or 0 to quit: 1

Enter the number of miles as a whole number:500

Enter the weight of the package in pounds:6

The cost to ship your package is: $3.70.

Enter 1 to continue or 0 to quit: 1

Enter the number of miles as a whole number:500

Enter the weight of the package in pounds:11

        Error: We don't shippackages over 10 pounds!

Enter the weight of the package in pounds:10

The cost to ship your package is: $5.25.

Enter 1 to continue or 0 to quit: 1

Enter the number of miles as a whole number:501

Enter the weight of the package in pounds:3.75

The cost to ship your package is: $7.40.

Enter 1 to continue or 0 to quit: 1

Enter the number of miles as a whole number:1000

Enter the weight of the package in pounds:6.1

The cost to ship your package is: $10.50.

Enter 1 to continue or 0 to quit: 1

Enter the number of miles as a whole number:12450

Enter the weight of the package in pounds:1

The cost to ship your package is: $37.50.

Enter 1 to continue or 0 to quit: 0

Good-bye!

Press any key to continue . . .

Create an IPO Diagram Here

Input

Process

Output

Test Case 1

Input Data

Expected Results

Weight:              1.5 pounds

Miles:                   200 miles (This is one 500-mile segment.)

Your shipping charge is $1.50.

Test Case 2

Input Data

Expected Results

Weight:              5.6 pounds

Miles:                   1200 miles (This is three 500-mile segments.)

Your shipping charge is $11.10.

Create Test Cases 3 – 5 Here

Your test cases must be unique, i.e., do NOT use theexamples in this document, except concerning those, which producean error. Make sure they are good, e.g., test for errors, beforeand after ends of ranges, etc. Feel free to include more test casesto thoroughly test your program.

Paste the Code Here

Paste any related Execution Windows (Screenshots) for AllCustomers, i.e., All Test Cases, Here

Post new questions in the Q & A discussion,if you are stuck or there is something in this, about which you areconfused.

Answer & Explanation Solved by verified expert
3.8 Ratings (412 Votes)
Note Could you plz go through this code and let me know if u need any changes in thisThank You    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students