At the moment my professor wants to do a program like below, I'm having difficulty achieving that, I'm seeking help to help me push through. Here is the instructions and what I have so far. Cristisim and advice accepted!
1) The highest score and the student name
2) The lowest score and the student name
3) Average score of the class
4) Display the student names and their scores in decreasing order of their scores with marks: if their score is above average, mark with a ‘+’ sign; if their score equals to average, mark with a ‘=’; otherwise, mark with a’-‘.
Example Image of what I have to do: https://i.gyazo.com/403819a89bae613452dd8278b0612d81.png
My problems are, I don't know how to sort the arrays to get the highest score and print it out with the corresponding name that goes with it. I also don't know how to put the numbers like 1. Name, 2. Name because it starts with 0 first.
My work:
public static void main(String[] args) {
System.out.println("********** Students and Scores ************");
Scanner input = new Scanner(System.in);
System.out.print("How many students in your class?: ");
int numStudents = input.nextInt();
double[] scores = new double[numStudents];
String[] students = new String[numStudents];
for (int i = 0; i < numStudents; i++) {
System.out.print(i + ". Name: ");
students[i] = input.next();
System.out.print("Score: ");
scores[i] = input.nextDouble();
}
double sum = 0;
for(int i=0; i < scores.length ; i++)
sum = sum + scores[i];
double average = sum / scores.length;
System.out.println("*************** Results *****************");
System.out.println("Average: " + average);
System.out.println("******* End of Students and Scores *********");
}