Cant receive input(userName) | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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); }

16th Mar 2022, 11:56 AM
Ayomisesebere
Ayomisesebere - avatar
2 Respostas
+ 2
Input : name age UserName in 2 lines only else use inputAge = Integer.parseInt(s.nextLine()) ; Hoping you declared all variables before..
16th Mar 2022, 12:30 PM
Jayakrishna šŸ‡®šŸ‡³
0
your input is: inputName; inputAge; inputUserName; but you print 4-th empty variable userName System.out.println("Welcome" + " "+ userName);
16th Mar 2022, 3:10 PM
zemiak