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
Step: 1
Errors and Corrections The errors youre encountering are due to several typos and missing imports Scanner Class Change scanner to Scanner casesensitiv...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