0

Exception in thread "main" java.util.NoSuchElementException (error)?? help

import java.util.Scanner; public class NewClass { public static void main(String[] args){ Scanner s = new Scanner(System.in); String name=""; int age= 0; double height= 0; System.out.print("what is your full name: "); name= s.nextLine(); System.out.print("what is your age?"); age=s.nextInt(); System.out.print("what is your height in cm?"); height = s.nextDouble(); s.close(); if (name.equals("Felix Robinson")&&age==22 && height==180){System.out.println("Welcome!");} else {System.out.println("access denied!");} int day; Scanner d = new Scanner(System.in); day= d.nextInt(); switch(day){ case 1: System.out.print("monday"); break; case 2:System.out.print("tuesday"); break; case 3: System.out.print("wednesday"); d.close(); break; } } } The output is this when i run the program: what is your full name: Felix Robinson what is your age?22 what is your height in cm?180 Welcome! Exception in thread "main" java.util.NoSuchElementException at java.util.Scanner.throwFor(Unknown Source) at java.util.Scanner.next(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at java.util.Scanner.nextInt(Unknown Source) at NewClass.main(NewClass.java:23)

25th Sep 2016, 1:48 AM
Felix Robinson
Felix Robinson - avatar
1 Resposta
0
try: height = 0.0 before, 1.80 after input
4th Oct 2016, 7:54 PM
Wanderlei Borges
Wanderlei Borges - avatar