0
Cant receive input(userName)
/*The method below is supposed to receive three inputs from the user and then display a welcome message, welcoming the user by his/her inputted userName. But instead, the code receives only the first two inputs and at the end of the method execution, displays "Welcome ". Below is the problematic code. Your assistance is appreciated.*/ public void initiation(){ System.out.println("What's your name?"); inputName = s.nextLine(); System.out.println("Whats your age?"); inputAge = s.nextInt(); System.out.println("Your desired username?"); inputUserName = s.nextLine(); System.out.println("Welcome" + " "+ inputUserName); }
2 Antworten
+ 2
Input :
name
age UserName
in 2 lines only else use
inputAge = Integer.parseInt(s.nextLine()) ;
Hoping you declared all variables before..
0
your input is:
inputName;
inputAge;
inputUserName;
but you print 4-th empty variable
userName
System.out.println("Welcome" + " "+ userName);