Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Online Shipping Calculator (Java) Purpose: Compute the cost of shipping for an online store. Procedures: The user enters the weight of the item to be

Online Shipping Calculator (Java) Purpose: Compute the cost of shipping for an online store. Procedures: The user enters the weight of the item to be shipped and the shipping destination. The application computes the total shipping cost. Algorithms, Processing and Conditions: A user enters the weight in pounds and selects the destination for the delivery. The user can select U.S. standard delivery by entering 'U' or international delivery by entering an 'L' for Latin America or 'C' for Canada. If the item weighs less than 5 pounds the standard rates apply. If the item weighs more than 5 pounds, add a 25% surcharge to the standard rates. The shipping rates are $6.00 for the U.S., $8.00 for Latin America or Canada. If the customer requests overnight shipping, double the shipping cost. The total cost for shipping is displayed. Notes and Restrictions: If the user enters a negative weight, inform the user and ask for a valid weight. If the value entered is greater than 20 pounds, the user should be advised and asked for a valid weight. The shipping cost should be displayed in currency format. import java.util.Scanner; import java.text.DecimalFormat; public class onlineShipping { public static void main(String[] args) { Scanner kbd = new Scanner(System.in); DecimalFormat fmt = new DecimalFormat(\"#.00\"); //define constants for the shipping costs /* Type your code here. */ //define variables double ; String ; //get the weight of the item to ship must be //greater than 0 and less than of equal to 20 lbs. System.out.println(\"Enter the shipping weight of the item: \"); weight = kbd.nextDouble(); //make sure the weight is valid if(/*your code here*/) { //grab the next character in the input buffer and ignore it loc = kbd.nextLine(); //determine where to ship to /* Type your code here. */ //use switch and case to determine the initial cost to ship switch() { case \"U\": case \"u\": /* Type your code here. */ } //now we know the shipping cost let's determine if we need add the surcharge /* Type your code here. */ //and if its overnight /* Type your code here. */ //tell the user how much to ship the item /* Type your code here. */ } else System.out.println(\"Item must weigh between 0 and 20 pounds.\"); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Financial Accounting

Authors: Robert Libby, Patricia Libby, Daniel Short, George Kanaan, M

5th Canadian edition

9781259105692, 978-1259103285

More Books

Students also viewed these Programming questions