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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:18:29+00:00 2026-06-15T13:18:29+00:00

What I’m attempting to do is search gradePsd array find the highest grade and

  • 0

What I’m attempting to do is search “gradePsd” array find the highest grade and if there are two grades that are the same value print the name (s) of the students to console.

The problem I’m having is that this method is taking the first index value of the array and printing it because it IS the high value at the first pass and if the second value is larger than the first then it will also print and so on.

So my question is how can I get it to just print the student (s) with the high grade.

public static void hiMarkMethod(String[] NamePsd, int[] gradePsd)
{
    String nameRtn = "";
    int num = gradePsd[0];

    System.out.println ("\n\nThe Student(s) with Hightest Mark(s) are:");

    for (int  i = 0; i < gradePsd.length;  i++)
    {
        if (gradePsd[i] >= num)
        {
            num = gradePsd[i];
            nameRtn = NamePsd[i]; 
        }

        System.out.print(nameRtn + ", ");
    }
}
  • 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-15T13:18:30+00:00Added an answer on June 15, 2026 at 1:18 pm

    first find the highest number
    then print the students with that number

    public static void hiMarkMethod(String[] NamePsd, int[] gradePsd)
        {
    
        String nameRtn = "";
        int num = gradePsd[0];
    
         System.out.println ("\n\nThe Student(s) with Hightest Mark(s) are:");
        //find the highest number
        for (int  i = 0; i < gradePsd.length;  i++){
        if (gradePsd[i] >= num){
            num = gradePsd[i];
        }
        //print students with that number
        for (int  j = 0; j < NamePsd.length;  j++){
            if (gradePsd[j] == num)
            {
                nameRtn = NamePsd[j]; 
                System.out.print(nameRtn + ", "); 
            }
        }
    

    one of possible 1000 solutions.

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

Sidebar

Related Questions

I am attempting to search through an array list to find a value (which
So I am attempting to create a search field that will filter contacts on
I have a search query that I'm inheriting and attempting to optimize. I am
Using sed, I am attempting to recursively search and replace a string foo that
I am attempting to write (or expand on an existing) graph search algorithm that
I'm attempting to write a search function for a database table that needs to
I am attempting to use a recursive function to search through a multidimensional array,
I am attempting to search a user input array of text with another user
I'm attempting to use regexp to parse a search string that from time to
I'm attempting to create a search function, built something like this: function Search(array, key,

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.