Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #34855
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2016-07-11 12:00 -0700 |
| Message-ID | <87b76adc-9800-410f-ac5a-3cd25588bb3a@googlegroups.com> (permalink) |
| Subject | Scanner error |
| From | kalisha malama <malamakalisha@gmail.com> |
Hello All,
Am so new to programming. I need your help. am getting the following error
import java.util.Scanner;
class Apples {
public static void main(String args[]){
Scanner myScanner = new Scanner(System.in);
int age;
double price = 0.00;
char reply;
System.out.print("How old are you ?");
age = myScanner.nextInt();
System.out.print("Do you have a Coupon?(Y/N)");
reply = myScanner.findInLine(".").charAt(0);
if (age >= 13 && age <60){
price = 9.30;
}
if (age < 13 && age >= 60){
price = 5.90;
}
if (reply == 'Y' || reply == 'y'){
price -=2.00;
}
if (reply !='Y' && reply != 'y' &&
reply !='N' && reply !='n'){
System.out.println("Next Serious Customer");
}
System.out.print ("Please Pay $");
System.out.print ("price");
System.out.print (".");
System.out.println("Thank You. Enjoy Your Diner");
}
}
error message
How old are you ?21
Do you have a Coupon?(Y/N)Exception in thread "main" java.lang.NullPointerException
at Apples.main(Apples.java:15)
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Scanner error kalisha malama <malamakalisha@gmail.com> - 2016-07-11 12:00 -0700
Re: Scanner error Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-11 15:22 -0400
Re: Scanner error Eric Sosman <esosman@comcast-dot-net.invalid> - 2016-07-11 15:26 -0400
Re: Scanner error Lew <lewbloch@gmail.com> - 2016-07-11 13:12 -0700
Re: Scanner error Eric Douglas <e.d.programmer@gmail.com> - 2016-07-11 13:58 -0700
csiph-web