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

  • SEARCH
  • Home
  • 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 7803467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:35:37+00:00 2026-06-02T01:35:37+00:00

I am attempting to read each integer from an infile and passing that on

  • 0

I am attempting to read each integer from an infile and passing that on to the method adScore which determines the letter grade, and total count of all the grades and the highest exam score and lowest exam score. But my while loop when doing the for loop isn’t pulling in the data from the infile as I am debugging it after the for loop doing a system.out.print. And what returns are just the numbers 0-29 which is my counter in the loop. Can assist me as to what I am doing wrong so that I can pull in the grade scores from the infile?

Regards.

        while(infile.hasNextInt())
        {
            for(int i=0; i <30; i++)//<-- it keeps looping and not pulling the integers from the     file.
            {
                System.out.println(""+i);//<--- I placed this here to test what it     is pulling in and it is just counting
                //the numbers 0-29 and printing them out.  How do I get each data    from the infile to store
                exam.adScore(i);//determines the count of A, B, C, D, F grades, total   count, min and max
            }
        }
  • 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-06-02T01:35:39+00:00Added an answer on June 2, 2026 at 1:35 am

    Tron’s right — you haven’t actually asked the scanner to read the next integer. Scanner.hasNextInt() simply tests to see if there’s an integer to be read. You’re just telling i to loop through the values 0-29. I think you mean to do something like this:

    while(infile.hasNextInt())
    {
        int i = infile.nextInt();
        exam.adScore(i);//determines the count of A, B, C, D, F grades, total count, min and max
    }
    

    If you’re not sure that every line in the input is an integer, you could do something like this:

    while(infile.hasNext()) { // see if there's data available
        if (infile.hasNextInt()) { // see if the next token is an int
            int i = infile.nextInt(); // if so, get the int
            exam.adScore(i);//determines the count of A, B, C, D, F grades, total count, min and max
        } else {
            infile.next(); // if not an int, read and ignore the next token
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ListBox that gets populated with items read from a JSON response.
I am attempting to read hex values from a text file. There can be
I am currently attempting to read in Hex values from a text file. There
I've got a web application that controls which web applications get served traffic from
While attempting to read data from memory into an enum via the following code,
I'm attempting to use an AsyncTask to read from a file at regular intervals.
I am attempting to create a template that will utilize data from an Access
I'm receiving an error when I'm attempting to consume a web service: Cannot read
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to make a NSObject called 'Person' that will hold the login details for

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.