/* CSC 17 OOP Assignment (lab 5) Due one week from date assigned A programmer who thinks that he knows Java and object oriented programming was asked to write a program to keep track of students at a university. There are two kinds of students: grads and undergrads. All students have a name and a gpa and take a certain number of credit hours. Graduate students have a thesis topic while undergraduates have a major. The algorithm to compute the tuition for grads is also different from that for undergrads. Our programmer created the following program. Not only is it not really object oriented (no meaningful use of dynamic dispatch), but because he relied on too many if and if-else statements, there is a mistake in the program (can you figure out where?) Your task is to rewrite the program using an abstract class and inheritance and take advantage of dynamic dispatch. First, study the program to understand how it works and what it's supposed to do. Be sure to run it to see what happens. Then follow the instructions in comments at the end. */ class student { public final String name; protected boolean isgraduate = false; // is this student a grad student? protected double gpa; protected int credits; // number of credit hours taken protected String major=null; // used only for undergraduates protected String thesistopic=null; // used only for graduates public boolean isgraduate() { return isgraduate;} static String[] mjs= {"comp sci", "poly sci", "engineering", "math", "physics","biology","psychology", "history", "leisure studies"}; static String[] topics = {"p equals np", "halting problem", "distributed os", "real time fault tolerance", "compiler design", "cryptography", "machine learning"}; // constructor takes name and graduate/undergrad flag, randomizes rest public student(String n, boolean g) { name = n; isgraduate = g; gpa = ((int)(Math.random()*401))/100.0; // set random gpa credits = 3 + (int)(Math.random()*15); //number of credits being taken if (isgraduate) thesistopic = topics[(int)(Math.random()*topics.length)]; else major = mjs[(int)(Math.random()*mjs.length)]; }//student constructor // compute tuition: undergrads pay $1200 per credit, grads pay $1600 public double tuition() { if (isgraduate) return 1600*credits; else return 1200*credits; } }// student class public class stu1 { public static void main(String[] argv) { String[] names = {"Matthew","Taiga","Michael","Stefan","Piper","Jules","Ahmed","Christopher","Ricky","Yonghyeon","Dylan","Peyton","Tito","Kevin","Max","Nishad","David","Justin"}; student[] roster = new student[names.length]; // create random roster of students, alternating between grads and // undergrads for(int i=0;i