import java.util.Scanner;
class Helpful {
public static void main(String args[]) {
Scanner myScanner = new Scanner(System.in);
int age;
double price = 0.00;
char reply;
boolean isKid, isSenior, hasCoupon, hasNoCoupon;
System.out.print("How old are you? ");
age = myScanner.nextInt();
System.out.print("Have a coupon? (Y/N) ");
reply = myScanner.findInLine(".").charAt(0);
isKid = age < 12;
isSenior = age >= 65;
hasCoupon = reply == 'Y' || reply == 'y';
hasNoCoupon = reply == 'N' || reply == 'n';
if (!isKid && !isSenior) {
price = 9.25;
}
if (isKid || isSenior) {
price = 5.25;
}
if (hasCoupon) {
price -= 2.00;
}
if (!hasCoupon && !hasNoCoupon) {
System.out.println("Huh?");
}
System.out.print("Please pay $");
System.out.print(price);
System.out.println(".");
System.out.println("Enjoy the movie!");
}
}
// below is wat comes up when i hit execute (i type the 34 and hit enter, and the next thing that comes up should make me chose between 'Y' and 'N' but it doesn't)
How old are you? 34
Have a coupon? (Y/N) Exception in thread "main" java.lang.NullPointerException
at Helpful.main(Helpful.java:16)
Process completed.