Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

what is incorrect? I can't calculate. import javafx.application.Application; import javafx.application.Platform; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.layout.*; import javafx.scene.control.*; import javafx.stage.Stage; import javafx.event.ActionEvent; import javafx.event.EventHandler; public

what is incorrect? I can't calculate. import javafx.application.Application; import javafx.application.Platform; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.layout.*; import javafx.scene.control.*; import javafx.stage.Stage; import javafx.event.ActionEvent; import javafx.event.EventHandler; public class MealCalculator extends Application implements EventHandler { private String[] dormNames = {"Allen Hall", "Pike Hall", "Farthing Hall", "University Suites"}; private String[] mealPlans = {"7 meals per week", "14 meals per week", "Unlimited meals per week"}; Stage window; Scene scene; Button calcButton; ComboBox dormComboBox; ComboBox mealComBox; public static void main(String[] args) { launch(args); } public void start(Stage primaryStage) throws Exception { Stage window = primaryStage; window.setTitle("Dorm and Meal Plan Calculator"); BorderPane bPane = new BorderPane(); bPane.setPadding((new Insets(15, 20, 10, 10))); VBox box1 = new VBox(10); Label lbl1 = new Label("Choose Dorm"); Label lbl2 = new Label("Choose meal Plan "); bPane.setLeft(box1); box1.getChildren().addAll(lbl1, lbl2); VBox box2 = new VBox(10); dormComboBox = new ComboBox<>(); dormComboBox.getItems().addAll( "Allen Hall", "Pike Hall", "Farring Hall", "University Suits"); mealComBox = new ComboBox<>(); mealComBox.getItems().addAll( "7 meals per week", "14 meals per week", "Unlimited meals"); bPane.setCenter(box2); box2.getChildren().addAll(dormComboBox, mealComBox); HBox bottom = new HBox(20); calcButton = new Button("Calculate"); Button exitButton = new Button("Exit"); bottom.setPadding(new Insets(15, 20, 10, 10)); bPane.setBottom(bottom); bottom.getChildren().addAll(calcButton, exitButton); calcButton.setOnAction(this); exitButton.setOnAction(e -> Platform.exit()); Scene scene = new Scene(bPane, 300, 250); window.setScene(scene); window.show(); } public void handle(ActionEvent event) { String selectedDorm; String selectedMealPlan; double dormCharges; double mealCharges; double totalCharges; selectedDorm = dormComboBox.getValue(); if (selectedDorm.equals("Allen Hall")) dormCharges = 1500.0; else if (selectedDorm.equals("Pike Hall")) dormCharges = 1600.0; else if (selectedDorm.equals("Farthing Hall")) dormCharges = 1200.0; else if (selectedDorm.equals("University Suites")) dormCharges = 1800.0; else  dormCharges = 0.0; selectedMealPlan = mealComBox.getValue(); if (selectedMealPlan.equals("7 meals per week")) mealCharges = 560.0; else if (selectedMealPlan.equals("14 meals per week")) mealCharges = 1095.0; else if (selectedMealPlan.equals("Unlimited meals per week")) mealCharges = 1500.0; else  mealCharges = 0.0; } } 

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

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

Did the decisions need to be made, or had they already been made?

Answered: 1 week ago

Question

When there was controversy, was it clear who had the final say?

Answered: 1 week ago