Question: what am i doing wrong? import java.util.Scanner; public class LabProgram { public static void main(String[] args) { scanner sc = new

what am i doing wrong?

 

import java.util.Scanner;

public class LabProgram {
  public static void main(String[] args) {
     scanner sc = new scanner(scanner.in);
     
     double milesPerGallon = sc.nextDouble();
     double dollarPerGallon = sc.nextDouble();
     
     double gallonPerMile = 1.0 / milesPergallon;
     double costPer20miles = gallonPerMile * 20 * dollarPerGallon;
     double costPer75miles = gallonPerMile * 75 * dollarPerGallon;
     double costPer500miles = gallonPerMile * 500 * dollarPerGallon;
     
     system.out.printf("%.2f",coastPer20Miles);
     system.out.printf("%.2f",coastPer75Miles);
     system.out.printf("%.2f",coastPer500Miles);
  }
}
 

 

 

Errors that are returned to me when running the program

LabProgram.java:5: error: cannot find symbol scanner sc = new scanner(scanner.in); ^ symbol: class scanner location: class LabProgram LabProgram.java:5: error: cannot find symbol scanner sc = new scanner(scanner.in); ^ symbol: class scanner location: class LabProgram LabProgram.java:5: error: cannot find symbol scanner sc = new scanner(scanner.in); ^ symbol: variable scanner location: class LabProgram LabProgram.java:10: error: cannot find symbol double gallonPerMile = 1.0 / milesPergallon; ^ symbol: variable milesPergallon location: class LabProgram LabProgram.java:15: error: cannot find symbol system.out.printf("%.2f",coastPer20Miles); ^ symbol: variable coastPer20Miles location: class LabProgram LabProgram.java:15: error: package system does not exist system.out.printf("%.2f",coastPer20Miles); ^ LabProgram.java:16: error: cannot find symbol system.out.printf("%.2f",coastPer75Miles); ^ symbol: variable coastPer75Miles location: class LabProgram LabProgram.java:16: error: package system does not exist system.out.printf("%.2f",coastPer75Miles); ^ LabProgram.java:17: error: cannot find symbol system.out.printf("%.2f",coastPer500Miles); ^ symbol: variable coastPer500Miles location: class LabProgram LabProgram.java:17: error: package system does not exist system.out.printf("%.2f",coastPer500Miles); ^ 10 errors

 

what am i doing wrong

Step by Step Solution

3.40 Rating (153 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Errors and Corrections The errors youre encountering are due to several typos and missing imports Scanner Class Change scanner to Scanner casesensitiv... View full answer

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 Programming Questions!