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:937)
at java.base/java.util.Scanner.next(Scanner.java:1594)
at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
at LabProgram.main(LabProgram.java:15) 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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago