## Question

Write a java program that has a class “Fraction” that has does the following: The user should be able to input two fractions (command line is fine), the program should ensure that the denominator is not 0 in any case, and the user should be able to add, subtract, multiply or divide those two fractions together. You can assume these are signed integers and that the number ranges will be small (not exceeding 32 bit architecture limits) – so don’t worry about big integers or that sort of thing. You do not need to implement a ‘reduce’ function. Users should be able to Print the fraction as well, which should produce both the fraction in a numerator/denominator format as well as a floating point result (3 decimal places is fine).

Java does not support operator overloading (so don’t try).

A Fraction should have an integer numerator and integer denominator, at given time you could have up to 3 fraction objects.

The program should run in loop and allow the user to exit with some special character input (e.g. x or X to exit), but otherwise keep getting fractions to do basic math on, then print the result.

In a MS Word (or similar) document please provide examples of how you tested the program (input and output, remember though: the program does not need to reduce).

Question 2: UML.

Using the UML tool of your choice (I recommend UMLet) make a custom UML element that in the following style: It should have your name, a horizontal line, your student number, and the name of the degree program you are currently enrolled in, all centre justified. You should then export it in some way that you can import it into a word (or similar) document.

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;public class Fraction {

public int numerator, denominator;

public Fraction(int num, int den)

{

numerator = num;

denominator = den;

}

public void add(Fraction fraction)

{

if(fraction.denominator == denominator)

numerator = numerator + fraction.numerator;

else

{

numerator = numerator * fraction.denominator + fraction.numerator * denominator;

denominator = denominator * fraction.denominator;

}

}

public void subtract(Fraction fraction)

{

if(fraction.denominator == denominator)

numerator = numerator - fraction.numerator;

else

{

numerator = numerator * fraction.denominator - fraction.numerator * denominator;

denominator = denominator * fraction.denominator;

}

}...