Student Information Program Design and write an application program in Java that
ID: 3826646 • Letter: S
Question
Student Information Program
Design and write an application program in Java that keeps track of students’ information at the University.
The information tracked will be
student name
student ID number
and student GPA.
The user will be presented a menu. The menu should allow the user to
Create a new student and add that student to the list.
Display the entire list of of students
Delete a student from the list
Modify the information for (a new name or GPA) for a student
Write (save) all the student data to a specified file
Read the list of students from a specified file
Explanation / Answer
import java.util.Scanner;
class StudentList {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter number of students: ");
int numOfStu = input.nextInt();
int[] grades = new int[numOfStu];
String[] names = new String[numOfStu];
for (int i = 0; i < numOfStu; i++) {
String name = input.next();
int grade = input.nextInt();
names[i] = name;
grades[i] = grade;
System.out.println("");
}
for (int i = grades.length - 1; i > 0; i--) {
int currentMax = grades[0];
int currentMaxIndex = 0;
for (int k = 1; k <= i; k++) {
if (currentMax < grades[k]) {
currentMax = grades[k];
currentMaxIndex = k;
}
}
grades[currentMaxIndex] = grades[i];
grades[i] = currentMax;
String tempName = names[currentMaxIndex];
names[currentMaxIndex] = names[i];
names[i] = tempName;
}
for(int i=0; i<grades.length; i++)
System.out.println(names[i] + " " + grades[i]);
}
public static int[] reverseInt(int[] array) {
int[] poop = new int[array.length];
for (int i = 0, j = poop.length - 1; i < array.length; i++, j--) {
poop[j] = array[i];
}
return poop;
}
public static String[] reverseString(String[] array) {
String[] poop = new String[array.length];
for (int i = 0, j = poop.length - 1; i < array.length; i++, j--) {
poop[j] = array[i];
}
return poop;
}
}