Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Using BlueJ, create a new project named Chapter4 and complete the Programming Challenge 6, Shipping Charges on page 274. ignoring the 500 miles part.

JAVA

Using BlueJ, create a new project named Chapter4 and complete the Programming Challenge 6, Shipping Charges on page 274. ignoring the 500 miles part. Consider the rates are rates per kg.

Kilograms Rate per Kilogram
weight less than or equal 2 1.1
weight > 2 and less than or equal 6 2.2
weight > 6 and less than or equal 10 3.7
weight > 10 4.8

Use the attached Java source file as a starting point. Add code to the go and computeShippingCharges methods.

Also, copy the contents of the other attached file ShippingChargesTest,java into a BlueJ-created test class replacing the generated contents to verify your ShippingCharges.java is coded correctly.

Use the java.util.Scanner class for inputing values as shown in Chapter 2 of the book.

Grading criteria follow:

Only Java features introduced through the current textbook chapter should be utilized to complete the exercise.

If your program does not compile or fails with a runtime exception, the program will be returned with a grade of zero. Test you program; verify it runs. If you are having trouble getting it to compile or run without error, email me attaching a copy of the Java source files and request assistance.

If you do not follow the instructions in the eCampus lesson, you can lose up to 25 points.

This exercise expects you to use named constants, named with all capital letters and underscores separating words. A named constant in Java should be defined with the static and final keywords.

Variables and method names should be named using camel-case. Variables should be nouns (names) and methods names should begin with a verb (action) word.

Class names should always begin with a capital letter and only one class per source file.

Your ShippingCharges.java should be written per the given Class diagram.

Your grade will not be more than 90, if the given test class does not run.

USE THIS AS A STARTING POINT!

import java.util.Scanner; import java.text.DecimalFormat; /** * ITSW 2417 Chapter 4 Shipping Charges */ class ShippingCharges { public static final double RATE_UNDER_2KGS = 1.1; public static final double RATE_UNDER_6KGS = 2.2; public static final double RATE_UNDER_10KGS = 3.7; public static final double RATE_OVER_10KGS = 4.8; private void go() { DecimalFormat df = new DecimalFormat("0.00"); // Input weight double weight = 0.0; double shippingCharges = computeShippingCharges(weight); System.out.printf("$" + df.format(shippingCharges), "Shipping Charges for " + df.format(weight) + " KGs"); } double computeShippingCharges(double weight) { // logic to determine shipping charges using constants above return 0.00; } public static void main(String[] args) { new ShippingCharges().go(); } } 

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