Question: no main methods JavaFX applications applets or MIDlets found in file How can I fix this error in this following code? import java.text.DecimalFormat; public class

no main methods JavaFX applications applets or MIDlets found in file

How can I fix this error in this following code?

import java.text.DecimalFormat; public class CarApp { //// instance variables private String model; private int mpg; private double tankCapacity; private double gasInTank; private double odometer; private DecimalFormat df; //// constructor public Car (String modelIn, int mpgIn, double tankCapacityIn) { model = modelIn; mpg = mpgIn; tankCapacity = tankCapacityIn; gasInTank = tankCapacity; // gas tank starts full odometer = 0; df = new DecimalFormat("0.00"); } // Car //// instance methods // getters public String getModel () { return model; } public int getMPG () { return mpg; } // setters public void setMPG (int mpgIn) { mpg = mpgIn; } // other instance methods public void fillUp () { gasInTank = tankCapacity; } // fillUp public boolean isOutOfGas () { return (gasInTank == 0.0); } // outOfGas public String toString () { String str = new String(model + " gets " + mpg + " mpg and has a " + df.format(tankCapacity) + " gal tank with " + df.format(gasInTank) + " gals and an odometer reading of " + df.format(odometer)); return str; } // toString public void drive (int numMiles) { double possibleMiles = gasInTank * mpg; if (numMiles <= possibleMiles) { odometer = odometer + numMiles; gasInTank = gasInTank - numMiles / mpg; } // if else { odometer = odometer + possibleMiles; gasInTank = 0.0;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!