Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Develop a Java WindowBuilder application with the following specifications. The application will be used to convert from US/British (FPS) measurements to Metric measurements. The application

Develop a Java WindowBuilder application with the following specifications. The application will be used to convert from US/British (FPS) measurements to Metric measurements. The application will convert the following measurements: Miles-Km, Lbs/Kg, Ft/Meters, In/Cm and Deg Celcius/Deg Farenheight. Conversion can be done in both directions (FPS to Metric and Metric to FPS). Provide two TextBoxes, one for the FPS value and One for the Metric value. Depending on which one of the Textboxes the user enters the value in, the type of conversion should be determined. E.g. if Miles are entered, conversion will be done to Km and displayed in the Metric box and vice versa. You need five Buttons: 1) Miles-Km, 2)Lbs/Kg, 3)Ft/Meters, 4)In/Cm and 5)Deg Celcius/Deg Farenheight. When the user enters a value in one of the TextBoxes and clicks one of the 5 buttons, the corresponding conversion should be done and displayed on the OTHER TextBox. Please note that for C/F degree conversion negative numbers are allowed. All other conversions are done only using positive numbers.

I have most of this complete but I can't seem to get it to populate the answer in whichever text field I leave blank. For instance if I enter "1" on the left text field box for "US" measurements, hit the "Pound - KG" button, the right text field where the metric conversion should display remains blank. If I enter a number in both fields it converts fine, but I need to be able to only enter one number. What I have currently for an example of where I am stuck:

public void actionPerformed(ActionEvent e)

{ n1 = textNumber1.getText();

n2 = textNumber2.getText();

num1 = Double.parseDouble(n1);

num2 = Double.parseDouble(n2);

Double pound = (num1 * .45);

Double kgram = (num2 * 2.2);

if(n1.isEmpty())

{ textNumber1.setText((Double)kgram + "");

} else { textNumber2.setText((Double)pound + "");

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

The Structure Of The Relational Database Model

Authors: Jan Paredaens ,Paul De Bra ,Marc Gyssens ,Dirk Van Gucht

1st Edition

3642699588, 978-3642699580

Students also viewed these Databases questions

Question

6. What is process reengineering? Why is it relevant to training?

Answered: 1 week ago