Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions