Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

Before you start do the following to set up you work environment:

Create new project called UJ

Create new class called Student and copy Student.java file

Create new class called UJDemo and copy UJDemo.java file

Task #1 implement the Serializable interface

Task 1.1: add the import of the required classes in order to be able to complete this task

Task1.2: In order to simply save objects to a file, you have to serialize these objects. Therefore, the Student class must implement the Serializable interface.

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; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Master The Art Of Data Storytelling With Visualizations

Authors: Alexander N Donovan

1st Edition

B0CNMD9QRD, 979-8867864248

More Books

Students also viewed these Databases questions

Question

What is paper chromatography?

Answered: 1 week ago

Question

Explain the cost of capital.

Answered: 1 week ago