Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Change the code below to display as JOptionPane. The code should appear in dialog boxes like this to allow the user to input information. import

Change the code below to display as JOptionPane. The code should appear in dialog boxes like this to allow the user to input information.

image text in transcribed

import java.util.Scanner;

public class helpwithproblem { public static void main(String[] args) {

Scanner keyboard = new Scanner(System.in);

int numberOfPackages = 0; // number of packages to ship double weight = 0.0; // weight of the package int packageNumber = 0; //Each package has a number double shippingCharges = 0.0; // Shipping Charge int counter = 0; // Loop counter System.out.println("This program calculates shipping charges."); System.out.println("Please enter the number of packages:"); //input number of packages numberOfPackages = keyboard.nextInt(); while (counter

System.out.println("Please enter the package number:"); //input package number packageNumber = keyboard.nextInt();

System.out.println("Please enter the weight of package #" + packageNumber); //Input package weight //input package number weight = keyboard.nextDouble();

// validate weight to make sure it is not less than 0. while (weight

System.out.println("Invalid weight. Please enter a number greater than or = 0."); weight = keyboard.nextDouble(); } //end while loop for validating the weight

//You will need a print statement to print out the quarter and the number of the quarter that you are on System.out.printf("%-40s%-10s%40s ", "****************************************", ("PACKAGE " + packageNumber), "****************************************"); //You will need a printf statement to print 5 column headings System.out.printf("%-30s%-30s%-30s ", "Package Number", "Weight", "Shipping Charge");

//This begins the if structure for the determining the shipping charge if (weight =16 && weight =36 && weight

// Display the results //You will need a printf statement to print out the package number, weight, shipping charges System.out.printf("%-30d%-30.1f%-30.2f ", packageNumber, weight, shippingCharges);

counter = counter + 1; } //end of while loop that controls the running of the program

} //end of main } //end of class

Input ? Please enter the number of packages: OK Cancel

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

Students also viewed these Databases questions

Question

Find Io in the circuit shown using source transformation 12V 6KO 12

Answered: 1 week ago

Question

=+6 Who is the peer of the IA ?

Answered: 1 week ago

Question

=+herself to in terms of equity with regard to this assignment?

Answered: 1 week ago

Question

=+ What typical employee will the IA compare him/

Answered: 1 week ago