Question: I need help with my java program I keep getting the error code Exception in thread main java.lang.Error: Unresolved compilation problem: at drivingmiles.Main.main(Main.java:5) My program:
I need help with my java program I keep getting the error code Exception in thread "main" java.lang.Error: Unresolved compilation problem: at drivingmiles.Main.main(Main.java:5)
My program:
import java.util.*;
public class Main{
public static void main(String[] args){
float savings_yrs;
Scanner i = new Scanner(System.in);
System.out.print("Enter the local fuel price per gallon: ");
float fuel_price_gallon =i.nextFloat();
System.out.print("Enter the Estimated MPG of gas vehicle: ");
float estimated_mpg =i.nextFloat();
System.out.print("Enter the Estimated KWH per mile for EV: ");
float estimated_kwh =i.nextFloat();
System.out.print("Enter the utility KWH rate: ");
float utility_kwh =i.nextFloat();
System.out.print("Enter the total miles are driven per year: ");
float total_miles =i.nextFloat();
savings_yrs=((total_miles/estimated_mpg)*fuel_price_gallon)-((total_miles/estimated_kwh)*utility_kwh);
System.out.println("The potential savings per year on switching from gasoline to electric vehicle is: "+savings_yrs+"$");
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
