Question: I NEED THID FAST PLEASE I NEED IT IN JAVA COMPLETE THE CODE FOLLOW EACH COMMENT This UJ program will ask the user for three

I NEED THID FAST PLEASE I NEED IT IN JAVA COMPLETE THE CODE FOLLOW EACH COMMENT

This UJ program will ask the user for three students names, their major and their GPA. The program will then check the validity of the entered GPA. An exception will be thrown if an invalid GPA is entered using IllegalArgumentException class. After reading the required information, the student should create an object from the Student class and store it in the file as object type. The student needs to handle all the expected exceptions that might occur during the writhing or reading process from the file.

Note: there are specific Files associated with this lab exam.

package uj; //add line for Task 1.1: //------------------------ //add line for Task 1.2: public class Student { //fields private String StudentName; private double GPA; private String major; //constructor public Student(String sn,double gpa,String m){ StudentName=sn; GPA=gpa; major=m; } //set methods public void setStudentName(String sn){ StudentName=sn; } public void setGPA(double gpa){ GPA=gpa; } public void setMajor(String m){ major=m; } //get methods public String getStudentName(){ return StudentName; } public double getGPA(){ return GPA; } public String getMajor(){ return major; } }

---------------------

//import statments import java.util.Scanner; //add line here for Task 2: public class UJDemo { public static void main (String [] arg) { final int StudentNu=3; //specify the student number String studentN, //store student name studentM; //store student major double studentGPA; //store student GPA FileOutputStream outStream; ObjectOutputStream objectOutputFile; Student[] ujStudents=new Student[StudentNu]; Scanner input=new Scanner(System.in); //-------------------------------- System.out.println("This program will write 3 student objects"+ "into a file"); try{ //add line here for Task 3: for (int i=0;i5); //create a student object ujStudents[i]=new Student(studentN,studentGPA,studentM); //add line here for Task 5.1: input.nextLine(); } //add line here for Task 5.2: }catch(){ } //-------------------------------------- System.out.println("Now, this program will read student object "+ "from file "); boolean endOfFile=false; //flag to test to test if the end of file reach or not Student s; FileInputStream inStream; ObjectInputStream objectInputFile; try{ //add line here for Task 6.1: while (!endOfFile){ try{ //add line here for Task 6.2: System.out.print("the student name is "+s.getStudentName()); System.out.print(", his major is "+s.getMajor()); System.out.println(", and his GPA is "+s.getGPA()); }catch(EOFException e){ endOfFile = true; } } //add line here for Task 6.3: }catch(){ } catch(){ } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!