Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Description You are to modify your project 2 to incorporate GUI components of TextField, TextArea and Button with the following requirements. Write an

Project Description

You are to modify your project 2 to incorporate GUI components of TextField, TextArea and Button with the following requirements.

 

Write an application that calculates the shipping charge for a package, based on its weight in pounds and ounces. The user will input a six digit identification code, weight in pounds and ounces each in separate text fields. (You will have 3 text fields). After the interface is displayed and the user has completed the entry for the purchase, display the package ID, the weight in pounds and ounces and the shipping charge in a text area. The shipping charge is calculated using a shipping rate of $0.18 per ounce. Accumulate the total shipping charges for all of the packages and the number of packages processed and display each of these last 2 items in individual labels.

 

Interface Layout and Input

Include the fictitious name of your company as a label at the top of your pane, displaying the company name in a larger font than the rest of the fields in the interface.

Include the following labeled text fields for user input:

  • Package-identification code (a six-digit code which must be saved as text)
  • Weight of the packageone text field for pounds and another text field for ounces. (save each as whole number)

Include a button to trigger the calculations and display the results. Also, allow the last text field to trigger the calculations and display.

Include a text area for displaying the results of the current order.

Include individual labels for both the total accumulated shipping charges for all orders and the total number of packages processed for all orders.

Clear the text fields and put the focus in the first text field

Include a label at the bottom of the interface containing your name as the developer.

Processing

After the user has input the package ID code, the pounds and the ounces, convert the weight to ounces and calculate the cost based on a shipping rate of $.18 per ounce.

Accumulate the total shipping charges for all packages entered and the number of packages processed. (Note: Assume for each user processing is only one package)

Calculation hint: There are 16 ounces in a pound.

You must use constants for the shipping rate (.18) and the conversion rate of 16 ounces/pound.

Output

Display the package ID, the weight in pounds and ounces formatted as shown in the Weight column under Sample Data below and the shipping charge in the text area.

Display the total shipping charges for all packages and the number of packages processed in individual labels.

Format the Weight as ___ lb. ___ oz.

Format your shipping charge to include a dollar sign and 2 decimal places.

Other Requirements

You must ensure that you do not code your entire application in the main method. Use a constructor to build the user interface and the handle method of the EventHandler interface to respond to the user's entry and do the calculations needed. You must break the task into more methods than described above.

Also, try to use to position your fields so that the interface is readable (labels next to the matching text fields, etc. Use constants for the width and height of the frame. Remember that you can also help to determine the size of your components when you declare them. Extra spaces in a label or button could help to line up items for a better interface look.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

import javaxswing import javaawt import javaawteventActionEvent import javaawteventActionListener public class ShippingCalculator extends JFrame private static final int FRAMEWIDTH 400 private static ... 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_2

Step: 3

blur-text-image_3

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

Programming With Microsoft Visual Basic 2017

Authors: Diane Zak

8th Edition

1337102121, 9781337517058, 978-1337102124

More Books

Students also viewed these Programming questions

Question

please don't answer the question, the question will be deleted.

Answered: 1 week ago

Question

Calculate SE ( p ) for n=100 and the values of p given 16. p=.01

Answered: 1 week ago