Question: The error I ' m getting is: Exception in thread main java.util.NoSuchElementException at java.base / java . util.Scanner.throwFor ( Scanner . java: 9 3 7

The error I
'
m getting is: Exception in thread "main" java.util.NoSuchElementException
at java.base
/
java
.
util.Scanner.throwFor
(
Scanner
.
java:
9
3
7
)
at java.base
/
java
.
util.Scanner.next
(
Scanner
.
java:
1
5
9
4
)
at java.base
/
java
.
util.Scanner.nextInt
(
Scanner
.
java:
2
2
5
8
)
at java.base
/
java
.
util.Scanner.nextInt
(
Scanner
.
java:
2
2
1
2
)
at LabProgram.main
(
LabProgram
.
java:
1
5
)
Here's my code and see why I
'
m getting this through Zybooks Lab
3
.
8
: import java.util.Scanner;
public class LabProgram
{
public static void main
(
String
[
]
args
)
{
Scanner scnr
=
new Scanner
(
System
.
in
)
;
String firstName;
int wholeNumber;
String pluralNoun;
String genericLocation;
System.out.println
(
"
Enter a first name:
"
)
;
firstName
=
scnr
.
nextLine
(
)
;
System.out.println
(
"
Enter a whole number:
"
)
;
wholeNumber
=
scnr
.
nextInt
(
)
;
System.out.println
(
"
Enter a plural noun:
"
)
;
pluralNoun
=
scnr
.
next
(
)
;
System.out.println
(
"
Enter a generic location:
"
)
;
genericLocation
=
scnr
.
next
(
)
;
System.out.println
(
firstName
+
"
buys
"
+
wholeNumber
+
"
different types of
"
+
pluralNoun
+
"
at
"
+
genericLocation
+
"
.
"
)
;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!