Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a JavaFX application that converts from pounds tokilograms or kilograms to pounds. Include a pair of radiobuttons to indicate the direction of the conversion,

Write a JavaFX application that converts from pounds tokilograms or kilograms to pounds. Include a pair of radiobuttons to indicate the direction of the conversion, and a pair oftext fields (with appropriate labels) to allow input of thenumbers. Also include a "Convert" button, a "Clear" button, and aempty label where error messages can be displayed if necessary.

By default, the "Pounds to Kilograms" radio button should beselected. Whichever radio button is selected, the other textfield should be set as not editable. For example when the"Pounds to Kilograms" radio button is selected, the kilograms textfield should be uneditable. Also, whenever either radiobutton is clicked, both text fields and the error label should becleared of text.

Of course, the user's input is received as text and must beparsed to a double. If the user's input cannot be beconverted (because it is non-numeric), an exception will be thrownwhen the input is parsed. Catch the exception and output anappropriate error message in the label at the bottom of thescene.

Helpful hint:The controls can be laid out inrows by using HBoxes, although a GridPane will work better for theTextFields and their associated labels. The verticalalignment can achieved by placing the HBoxes and GridPane in anouter VBox.

Conversion Factor: 1 pound = 0.4535924kilograms

image

Weight Converter Pounds to Kilograms Pounds 12 Kilograms 5.443 kilograms Convert Clear Weight Converter Pounds to Kilograms Pounds Three Kilograms Convert Clear Invalid Input Kilograms to pounds Kilograms to pounds X Weight Converter Pounds to Kilograms Pounds 26.455 pounds Kilograms 12 Convert Clear Kilograms to pounds

Step by Step Solution

There are 3 Steps involved in it

Step: 1

import javafxapplicationApplication import javafxgeometryInsets import javafxgeometryPos import javafxsceneScene import javafxscenecontrolButton impor... 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

Java Programming

Authors: Joyce Farrell

9th edition

1337397075, 978-1337397070

More Books

Students also viewed these Programming questions