0

i need coding help

So my code looks like this: import java.util.Scanner; public class dryrun { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("What is your name? "); int b = sc.nextInt(); System.out.println("What is your quest? "); int c = sc.nextInt(); System.out.println("What is your favourite colour? "); int d = sc.nextInt(); System.out.println(b); System.out.println(c); System.out.println(d); } } So when I run this code it asks the first question, and then I type in the answer and hit enter to continue and it hits an error. What am I doing wrong?

1st Apr 2022, 4:04 PM
Ryan
3 Answers
+ 1
Where are you running? What is your input? And your are expecting name so it must be a string but accepting an integer value.. May you giving string, then it raise execetion...!!
1st Apr 2022, 4:33 PM
Jayakrishna 🇼🇳
0
System.out.println("What is your name? "); //int b = sc.nextInt(); String b = sc.nextLine();
1st Apr 2022, 8:29 PM
zemiak