java - How to print the minimum score from 1 array and a name from a different array that corresponds to the other array -


i need print minimum , maximum number each array , name of student different array corresponds number.

this have far.

import java.util.*; import java.util.arrays;

public class lab5a2 { public static void main(string[] args) {     scanner console = new scanner(system.in);    meals(console);  }  public static void meals(scanner console) {     system.out.print("how many grades ");     int people = console.nextint();     int subtotal = 0;     int min = 10000;     int max = 0;     int avg = 0;     int[] grades = new int[people];     (int = 1; <= people; i++) {         system.out.print("next grade? ");         int personcost = console.nextint();         subtotal = subtotal + personcost;         grades[i-1] = personcost;         if(max <personcost)         {           max = personcost;         }         if(min>personcost)           min = personcost;     }   string[] names = new string[people];  system.out.println("now names.");  (int j = 1; j <= people; j++) {         system.out.print("next name? ");         string name = console.next();          names[j-1] = name;    }      avg = subtotal/people;      int min = min;      int max = max;     int avg = avg;     int sum = subtotal;     system.out.println(min);     system.out.println(min);     system.out.println(arrays.tostring(grades));     system.out.println(arrays.tostring(names));       int hue = arrays.binarysearch(grades, min);      int huey = arrays.binarysearch(grades, max);   system.out.println(hue);   system.out.println(huey);      system.out.println("/*** statistics student data ***/");     system.out.println("max. grade = " + grades[huey] + " " + "(" + names[huey] + ")");     system.out.println("min. grade = " + grades[hue] + " " + "(" + names[hue] + ")");     system.out.println("avg. grade = " + avg);     system.out.println(arrays.tostring(grades));     system.out.println(arrays.tostring(names)); } } 

i know need use indexes dont know how


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -