Skip to content

Instantly share code, notes, and snippets.

@pepet96
Created February 17, 2014 05:14
Show Gist options
  • Save pepet96/9045105 to your computer and use it in GitHub Desktop.
Save pepet96/9045105 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
import java.io.*;
public class Juggling {
public static void main (String [] args) {
Scanner input = new Scanner(System.in);
String[] names = new String[30];
char asterisk = '*';
int total = 0;
System.out.println("Input the names of the students. End with a *");
for(int i = 0; i <= 30; i++){
names[i] = input.nextLine();
if(asterisk == names[i].charAt(0)){
break;
}
}
int[] grades = new int[30];
System.out.println("Input the grades now");
for(int j = 0; j <= 30; j++){
if(asterisk == names[j].charAt(0)){
break;
}
else{
grades[j] = input.nextInt();
total = j + 1;
}
}
for(int x = 0; x <= 30; x++){
if(asterisk == names[x].charAt(0)){
break;
}
else{
System.out.println("The student " + names[x] + " got a score of: " + grades[x]);
}
}
System.out.println("The total amount of students is of: " + total);
int largest = grades[0];
for(int y = 0; y < grades.length; y++){
if(grades[y]>largest){
largest = grades[y];
}
}
System.out.println("The highest score was of: " + largest);
System.out.println("People who got that score were: " );
for(int z = 0; z < grades.length; z++){
if(grades[z] == largest){
System.out.println(names[z]);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment