Hello Everyone, I am studying Computer Science at ITM University and I’ve come across a problem. Initially, our teacher cannot help me due to the AQA Guidelines. So I am sharing the coding problem here.
class Price {
public static void main(String args[]) {
Scanner keyboard = new Scanner (System.in);
int day;
double price = 0.00;
System.out.print("How many days would you like to reserve the game?: ");
day = keyboard.nextInt();
if (day >= 4 && day <= 5) {
price = 5.55;
System.out.print("You have chosen to reserve the game for " + day + " days! ");
System.out.println("Please pay £" + price + ". " + " Enjoy your game!");
}
if (day == 3) {
price = 3.45;
System.out.print("You have chosen to reserve the game for " + day + " days! ");
System.out.println("Please pay £" + price + ". " + " Enjoy your game!");
}
if (day >= 1 && day <= 2) {
price = 2.75;
System.out.print("You have chosen to reserve the game for " + day + " days! ");
System.out.println("Please pay £" + price + ". " + " Enjoy your game!");
}
if (day > 5 || day <= 0) {
System.out.println("Invalid Number - Days of Reservation Are 1-5 Only. Please Try Again.");
}
keyboard.close();
}
}
My problem is that this code works on Online Compilers such as on Interviewbit Java Compiler with no worries yet Eclipse reads the following error:
"Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Scanner cannot be resolved to a type
Scanner cannot be resolved to a type
at Price.main(Price.java:3)"
Can anyone suggest me or Provide some solution?
Thanks