Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some help debugging please, for some reason I'm getting the following error within this section in the code. Here is the code. package

image text in transcribed

I need some help debugging please, for some reason I'm getting the following error within this section in the code.

image text in transcribedimage text in transcribed

Here is the code.

package exercise32_6; import java.text.NumberFormat; import java.util.Locale; import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.BorderPane; import javafx.scene.layout.GridPane; import javafx.scene.layout.VBox; import javafx.stage.Stage; public class exercise32_6dp extends Application { // Text fields for US dollars, Canadian dollars, German marks // and British pounds private TextField tfUSDollars = new TextField(); private TextField tfCanadianDollars = new TextField(); private TextField tfEuro = new TextField(); private TextField tfBritishPounds = new TextField(); // Text fields for excahnge rates private TextField tfCanadianDollarsRate = new TextField(); private TextField tfEuroRate = new TextField(); private TextField tfBritishPoundsRate = new TextField(); // Button to convert currencies private Button btConvert = new Button("Convert"); // Number formater NumberFormat nfCanada = NumberFormat.getCurrencyInstance(Locale.CANADA); NumberFormat nfEuro = NumberFormat.getCurrencyInstance(Locale.GERMAN); NumberFormat nfUK = NumberFormat.getCurrencyInstance(Locale.UK); @Override // Override the start method in the Application class public void start(Stage primaryStage) { BorderPane pane = new BorderPane(); pane.setLeft(new Label("US Dollars")); pane.setCenter(tfUSDollars); pane.setRight(btConvert); GridPane gridPane = new GridPane(); gridPane.add(new Label("Exchange Rate"), 1, 0); gridPane.add(new Label("Converted Amount"), 2, 0); gridPane.add(new Label("Canadian Dollars"), 0, 1); gridPane.add(new Label("Euro"), 0, 2); gridPane.add(new Label("British Pounds"), 0, 3); gridPane.add(tfCanadianDollarsRate, 1, 1); gridPane.add(tfEuroRate, 1, 2); gridPane.add(tfBritishPoundsRate, 1, 3); gridPane.add(tfCanadianDollars, 2, 1); gridPane.add(tfEuro, 2, 2); gridPane.add(tfBritishPounds, 2, 3); VBox vBox = new VBox(5); vBox.getChildren().addAll(new Label("Enter Dollar Amount"), pane, new Label("Display Exchange"), gridPane); // Create a scene and place it in the stage Scene scene = new Scene(vBox, 400, 200); primaryStage.setTitle("Exercise36_06"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage btConvert.setOnAction(e -> process()); tfUSDollars.setAlignment(Pos.BOTTOM_RIGHT); tfCanadianDollars.setAlignment(Pos.BOTTOM_RIGHT); tfEuro.setAlignment(Pos.BOTTOM_RIGHT); tfBritishPounds.setAlignment(Pos.BOTTOM_RIGHT); tfCanadianDollarsRate.setAlignment(Pos.BOTTOM_RIGHT); tfEuroRate.setAlignment(Pos.BOTTOM_RIGHT); tfBritishPoundsRate.setAlignment(Pos.BOTTOM_RIGHT); tfCanadianDollars.setEditable(false); tfEuro.setEditable(false); tfBritishPounds.setEditable(false); } @SuppressWarnings("removal") private void process() { double USDollars = new Double(tfUSDollars.getText().trim()).doubleValue(); double rateCanada = new Double(tfCanadianDollarsRate.getText().trim()).doubleValue(); double rateGermany = new Double(tfEuroRate.getText().trim()).doubleValue(); double rateBritan = new Double(tfBritishPoundsRate.getText().trim()).doubleValue(); tfCanadianDollars.setText(nfCanada.format(USDollars*rateCanada)); tfEuro.setText(nfEuro.format(USDollars*rateGermany)); tfBritishPounds.setText(nfUK.format(USDollars*rateBritan)); } /** * The main method is only needed for the IDE with limited * JavaFX support. Not needed for running from the command line. */ public static void main(String[] args) { launch(args); } }
Exercise 36.6 Convert dollars to other currencies Write a program that converts U.S. dollars to Canadian dollars, German marks (Euros) and British pounds, as shown in Figure 36.18. The user enters the U.S. dollar amount and the conversion rate, and clicks the Convert button to display the converted amount

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

Advances In Databases And Information Systems Uropean Conference Adbis 2020 Lyon France August 25 27 2020 Proceedings Lncs 12245

Authors: Jerome Darmont ,Boris Novikov ,Robert Wrembel

1st Edition

3030548317, 978-3030548315

More Books

Students also viewed these Databases questions

Question

6. What is the time frame for your study?

Answered: 1 week ago