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 9219731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:10:58+00:00 2026-06-18T03:10:58+00:00

I am trying to get this problem to work right, what it does it

  • 0

I am trying to get this problem to work right, what it does it ask for some scores to be entered and then it is supposed to show the name of the person with the highest score. I am getting the last score entered as the highest score, the problem with that is the last score entered is not going to necessarily be the highest one entered. Any ideas on how I can fix this would be appreciated. This is homework and just so nobody says “use a list or array” we have not covered that in class and thus are not supposed to use it for this problem.

       public static void main(String[] args) 
       {
            // variables
            Scanner input = new Scanner(System.in);
            int count = 0;
            int numStudents;
            double grade = 0, highestGrade = 0;
            String name = "", highName = "";

            String numGrades =
                    JOptionPane.showInputDialog
                    ("How many student grades are you entering: ");
            numStudents = Integer.parseInt(numGrades);

            //for(int count = 0; count < numStudents; count++)
            while(count < numStudents)
            {
            // prompt for the user to enter grades
            String inputName =
                    JOptionPane.showInputDialog("Enter a student name: ");
            name = inputName;
            //name = input.next(inputName);

            String inputGrade = 
                   JOptionPane.showInputDialog("What is that students grade: ");
            grade = Double.parseDouble(inputGrade);
            //grade = input.nextDouble();

            count++; 
            //if(grade < highestGrade)
            if(highestGrade > grade)
            {
                name = highName;
                grade = highestGrade;
            }
            else 
            {
                continue;
            }        
            }
            JOptionPane.showMessageDialog
                    (null, "The student with the highest score is " + name + 
                    " with a grade of " + grade);           
        }
  • 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-18T03:10:59+00:00Added an answer on June 18, 2026 at 3:10 am
     if(highestGrade > grade)
                {
                    name = highName;
                    grade = highestGrade;
                }
    

    Since you want to find the highest grade and name, the above should be in reverse.

     if(grade > highestGrade )
                {
                    highName = name;
                    highestGrade = grade;
                }
    

    Also, print the found values:

         JOptionPane.showMessageDialog
                     (null, "The student with the highest score is " + highName +  
                      " with a grade of " + highestGrade);        
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to get this working but for some reason it's just not right.
I have a problem with this query trying to get a sum and a
So I am running into this problem. I am trying to use $.get() to
Trying to get this expression to work, can someone look at it and tell
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
I'm having a problem trying to get a recursive method to work in rails/ruby.
I've been trying to get my code to work exactly right, it works for
Hello I am new at Haskell and i'm having problems trying to get this
Been trying to get this up and running for a while now. Basically i
I am trying to get this piece of code working in C#, what I

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.