import java.util.Scanner;
public class JavaMovies {
Scanner det = new Scanner(System.in);
int age = det.nextInt();
public static void main(String[] args){
calculator();
}
public static void calculator(){
Scanner det = new Scanner(System.in);
String rMovie = "Attack of the nerds";
String mMovie = "Nerd lyfe";
String pgMovie = "Nerd adventures";
String gMovie = "Nerd playtime";
System.out.println("These are the movies that are playing this weekend"
+ rMovie
+ mMovie
+ pgMovie
+ gMovie);
System.out.println("Please input your age");
int age = det.nextInt();
System.out.print("Input the movie you wish to see:");
String x = det.nextLine(); //Program ends here...
if(x.equals("Attack of the nerds") & age > 17){
System.out.println("You can see Attack of the nerds");
}else if(x.equals("Attack of the nerds") & age < 18){
System.out.println("You can see attack of the nerds!");
}if(x.equals("Nerd lyfe")& age > 15){
System.out.println("You can see Nerd lyfe");
}else if(x.equals("Nerd lyfe")& age < 16){
System.out.println("You can not see Nerd lyfe");
}if (x.equals("Nerd adventures")& age > 10){
System.out.println("You can see Nerd adventures");
}else if(x.equals("Nerd adventures")& age < 11){
System.out.println("You can not see Nerd adventures");
}if(x.equals("Nerd playtime")& age > 5){
System.out.println("You can see Nerd playtime");
}else if(x.equals("Nerd playtime")& age < 6){
System.out.println("You can not see Nerd playtime");
}
}
}
Everything is alright up to the start of the if statements, what can I do to fix this?
Console output(using netbeans) run: These are the movies that are playing this weekendAttack of the nerdsNerd lyfeNerd adventuresNerd playtime Please input your age 14 Input the movie you wish to see:BUILD SUCCESSFUL (total time: 4 seconds)