Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Download the Activtity Exceptions project from activity.zipDownload activity.zip The Activity class does not do any exception checking. Modify it so that you handle any exceptions
Download the Activtity Exceptions project from activity.zipDownload activity.zip
The Activity class does not do any exception checking. Modify it so that you handle any exceptions that could occur. Note that you should not change Fraction.java.
Think carefully about your design and use good objectoriented principles in your implementation.
Submit a file pdf that contains:
Briefly describe your implementation:
Output of your code:
Submit your code java files:
Activity.javaimport java.util.Scanner;
Driver class
@author Wade Huber
public class Activity
public static void mainString args
Fraction sampleFraction new Fraction;
Scanner scan new ScannerSystemin;
System.out.print Enter the numerator: ;
sampleFraction.setNumeratorscannextInt;
System.out.print Enter the denominator: ;
sampleFraction.setDenominatorscannextInt;
System.out.println The fraction sampleFraction.getNumerator
sampleFraction.getDenominator is equal to sampleFraction.toMixedNumber;
scan.close;
Fraction class, including the ability to represent improper fractions
as mixed numbers.
Activity add exception handling.
@author Wade Huber
public class Fraction
private int numerator;
private int denominator;
Class constructor default to
Fraction
numerator ;
denominator;
Class constructor specifying values for numerator & denominator
@param numerator numerator of fraction
@param denominator denominator of fraction
Fractionint numerator, int denominator
this.numerator numerator;
this.denominator denominator;
@return numerator the numerator of the fraction
public int getNumerator
return numerator;
@param numerator the numerator of the fraction
public void setNumeratorint numerator
this.numerator numerator;
@return denominator the denominator of the fraction
public int getDenominator
return denominator;
@param denominator the denominator of the fraction
public void setDenominatorint denominator
this.denominator denominator;
Generate a string representing the fraction in mixed number format.
@return string representation of the fraction as a mixed number
public String toMixedNumber
String ret ;
int remainder numerator denominator;
ret numerator denominator;
ret ;
if remainder
ret Math.absnumerator denominator;
ret ;
ret Math.absdenominator;
return ret;
@return string representation of the fraction as a mixed number
public String toString
String ret Integer.toStringnumerator denominator;
return ret;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started