Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Upgrading Oracle Databases Oracle Database New Features

Authors: Charles Kim, Gary Gordhamer, Sean Scott

1st Edition

B0BL12WFP6, 979-8359657501

More Books

Students also viewed these Databases questions

Question

5. Recognize your ability to repair and let go of painful conflict

Answered: 1 week ago