Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Why am I getting a cannot be resolved error on my code? package application; import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control. * ; import
Why am I getting a cannot be resolved error on my code?
package application;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class RoadTripCostEstimator extends Application
public static void mainString args
Application.launchargs;
@Override
public void startStage primaryStage
primaryStage.setTitleRoad Trip Cost Estimator";
GridPane grid new GridPane;
grid.setHgap;
grid.setVgap;
grid.setPaddingnew Insets;
Label distanceLabel new LabelDistance:;
TextField distanceField new TextField;
ComboBox distanceUnitCombo new ComboBox;
distanceUnitCombo.getItemsaddAllMiles "Kilometers";
Label gasolineCostLabel new LabelGasoline Cost:";
TextField gasolineCostField new TextField;
ComboBox gasolineCostUnitCombo new ComboBox;
gasolineCostUnitCombo.getItemsaddAllDollarsGal "DollarsLiter;
Label gasMileageLabel new LabelGas Mileage:";
TextField gasMileageField new TextField;
ComboBox gasMileageUnitCombo new ComboBox;
gasMileageUnitCombo.getItemsaddAllMilesGalKmLiter;
Label numberOfDaysLabel new LabelNumber of Days:";
TextField numberOfDaysField new TextField;
Label hotelCostLabel new LabelHotel Cost per Day:";
TextField hotelCostField new TextField;
Label foodCostLabel new LabelFood Cost per Day:";
TextField foodCostField new TextField;
Label attractionsCostLabel new LabelAttractions Cost:";
TextField attractionsCostField new TextField;
Button calculateButton new ButtonCalculate;
Label resultLabel new LabelTotal Trip Cost:";
TextField resultField new TextField;
resultField.setEditablefalse;
grid.adddistanceLabel;
grid.adddistanceField;
grid.adddistanceUnitCombo;
grid.addgasolineCostLabel;
grid.addgasolineCostField;
grid.addgasolineCostUnitCombo;
grid.addgasMileageLabel;
grid.addgasMileageField;
grid.addgasMileageUnitCombo;
grid.addnumberOfDaysLabel;
grid.addnumberOfDaysField;
grid.addhotelCostLabel;
grid.addhotelCostField;
grid.addfoodCostLabel;
grid.addfoodCostField;
grid.addattractionsCostLabel;
grid.addattractionsCostField;
grid.addcalculateButton;
grid.addresultLabel;
grid.addresultField;
calculateButton.setOnActione
double distance Double.parseDoubledistanceFieldgetText;
double gasolineCost Double.parseDoublegasolineCostFieldgetText;
double gasMileage Double.parseDoublegasMileageFieldgetText;
int numberOfDays Integer.parseIntnumberOfDaysFieldgetText;
double hotelCost Double.parseDoublehotelCostFieldgetText;
double foodCost Double.parseDoublefoodCostFieldgetText;
double attractionsCost Double.parseDoubleattractionsCostFieldgetText;
double totalTripCost calculateTotalTripCostdistance gasolineCost, gasMileage, numberOfDays, hotelCost, foodCost, attractionsCost;
resultField.setTextStringformatf totalTripCost;
;
Scene scene new Scenegrid;
primaryStage.setScenescene;
primaryStage.show;
private double calculateTotalTripCostdouble distance, double gasolineCost, double gasMileage, int numberOfDays, double hotelCost, double foodCost, double attractionsCost
double gasolineCostInLiters distance distanceUnitCombogetValueequalsMiles : gasMileage gasMileageUnitCombogetValueequalsMiles per Gallon" : ;
double totalTripCost gasolineCostInLiters gasolineCostUnitCombogetValueequalsDollars per Gallon" : gasolineCost
hotelCost foodCost numberOfDays attractionsCost;
return totalTripCost;
hotelCost foodCost numberofDays attractionsCost;
return totaltripCost;
Exception in thread "JavaFx Application Thread" java.lang.Error: Unresolved compilation problems:
distanceUnitCombo cannot be resolved
gasMileageUnitCombo cannot be resolved
gasolineCostunitCombo cannot be resolved
at application.RoadTripCostEstimator.calculateTotalTripCost RoadTripCostEstimatorjava:
at application.RoadTripCostEstimator.lambda$$
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started