Question: 8.1 Programming Fraction - Write in Java and include comments Consider the following class: public class Fraction{ private int numerator; private int denominator; private static

8.1 Programming Fraction - Write in Java and include comments

Consider the following class:

public class Fraction{ private int numerator; private int denominator; private static char slash = /, }

Write a program to instantiate an object of the Fraction class to test the class.. Add a constructor(s), set and get methods to the Fraction class appropriately. Using the Serializable Interface, instantiate and write three Fraction objects to a file called SerialF.dat. A loop must be used when creating and writing the three objects to the file. You can select the values you wish to use for the denominator and numerator.

Directions

Create the Fraction Class.

Add a constructor(s), set and get methods to the Fraction class appropriately.

Ensure the class is Serializable.

Use a loop to create three Fraction objects.

Initialize the three objects,

Write each object to the fileSerialF.dat.

Display an appropriate message if an exception occurs.

Grading Rubric

Task

Points

Fraction class implements Serializable

0.5

The main method throws an IOException

1

The file "SerialF.dat" is created properly

1

Loop used to instantiate objects

1

Objects are correctly written to file "SerialF.dat"

1

The file "SerialF.dat" is closed appropriately

0.5

Proper documentation

1

Program works effectively

1

Total

7

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!