Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1095447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:07:34+00:00 2026-05-17T00:07:34+00:00

I run the program, but none of my lines execute. When I tell it

  • 0

I run the program, but none of my lines execute. When I tell it to stop it prints a red error message.

Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)
at java.util.Scanner.nextInt(Unknown Source)

Here’s my code, nothing really seems to be out of the ordinary to my limited experience and my IDE doesn’t report any errors while I’m writing it.

import java.util.Scanner;

public class 312easf2 
{

    public static void main(String[] args) 
    {
        Scanner keyboard = new Scanner(System.in);
        int grade = 0;  // initial value to satify loop condition
        double averageGrade = 0.0;
        int max = keyboard.nextInt();
        int min = max;
        int next = keyboard.nextInt();

        System.out.println("Enter a nonnegative integer (negative to stop): ");

        while(next >= 0);
        {
            if(next > max)
                max = next;
            else if(next < min);
                min = next;
            next = keyboard.nextInt();
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:07:34+00:00Added an answer on May 17, 2026 at 12:07 am

    EDIT: I point out a syntax gotcha in my answer, which you still have to fix before your program will work correctly, but for now the real problem lies in your first few lines:

            Scanner keyboard = new Scanner(System.in);
            int grade = 0;  // initial value to satify loop condition
            double averageGrade = 0.0;
            int max = keyboard.nextInt();
            int min = max;
            int next = keyboard.nextInt();
    

    Your program is executing something but it’s saying nothing, and printing the error only when you stop, all because of a mistake in your program’s implementation. It’s not a syntax error, however; it’s just that you forgot something important here.

    Wcrousse in his answer explains what’s happening.


    There is a syntax issue are multiple similar syntax issues somewhere in your code that are actually legal syntax, which is why your IDE and the compiler aren’t complaining. However, they’re more often really a very common mistake that causes unintended behavior.

    Pay particular attention to your semicolons, and try looking through your code again. Or, use your debugger as Gabe suggests, that’ll give you a better idea what’s happening.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey everyone, I am trying to run the following program, but am getting a
I tried to package a Twisted program with py2exe, but once I run the
I've been trying to run my java program overnight but I need to restart
How should I run another program from within my C program? I need to
When I run the program from IDE (VS2008) it works perfectly. When I want
We have a Java program run as root on Unix, that therefore can read
Suppose you need to run a program on the world’s fastest supercomputer which will
I am new to Java and am trying to run a program using Eclipse.
I was wondering is there is a fool-proof way to run a program on
I have the following layout for my test suite: TestSuite1.cmd: Run my program Check

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.