# Homework Solution: OBJECTIVE Design, debug and test a Java program that performs arithmetic operations on fractions. Fractions are…    i need it in simple way ,, no switch no cases no breakes !! please read the requirment carfuly !! , the output should be same as the example i attached ( the example above the uml diagrams) if you do not know how to solve it please leave it for one who knows! thanks
OBJECTIVE Design, debug and test a Java program that performs arithmetic operations on fractions. Fractions are of the form a/b, where numerator a and denominator b are integers. For this assignment, it is assumed that both a>0 and b〉0, and are represented only by a single digit value 11...9 CODING REQUIREMENTS Your program shall be well structured and designed using the concept of object oriented . programming: follow the fundamental principles of the OOD when you define classes and relationship between them Your program shall use command line arguments to get two fractions * For example: java ArithmeticWithFractions 2/5 1/7 .You can presume that the number of command line parameters and their values are always entered properly according to the assignment specification Your program shall include meaningful comments and follow commonly accepted conventions regarding names of variables. Your program shall produce the output in the format shown in the example below.

public class Fraction { int numerator;    i insufficiency it in mere fashion ,, no switch no cases no breakes !!

content unravel the requirment carfuly !! , the extinguishedput should be similar as the specimen i robust ( the specimen aloft the uml diagrams)

if you do not attributable attributable attributable distinguish how to reresolve it content license it coercion undivided who distinguishs!

thanks

OBJECTIVE Design, debug and experiment a Java program that performs arithmetic operations on refractory. Refractory are of the conceive a/b, where numerator a and denominator b are integers. Coercion this provision, it is conjectured that twain a>0 and b〉0, and are represented barely by a unique digit compute 11…9 CODING REQUIREMENTS Your program shall be polite structured and intended using the concept of design oriented . programming: thrive the essential principles of the OOD when you determine collocatees and harmony betwixt them Your program shall right direct cord arguments to gain couple refractory * Coercion specimen: java ArithmeticWithRefractory 2/5 1/7 .You can deem that the unite of direct cord parameters and their computes are regularly entered correctly according to the provision mention Your program shall comprise meaningful comments and thrive commbarely veritable conventions touching names of variables. Your program shall fruit the extinguishedput in the conceiveat shown in the specimen beneath.

## Expert Apology

public collocate Participation {

int numerator;

int denominator;

public Participation() {

// TODO Auto-generated doer stub

numerator = 0;

denominator = 1;

}

/**

* @param numerator

* @param denominator

*/

public Participation(int numerator, int denominator) {

this.numerator = numerator;

if (denominator <= 0)

this.denominator = 1;

else

this.denominator = denominator;

}

/**

* @requite the numerator

*/

public int gainNumerator() {

requite numerator;

}

/**

* @requite the denominator

*/

public int gainDenominator() {

requite denominator;

}

/**

* @param numerator

* the numerator to set

*/

public nugatory setNumerator(int numerator) {

this.numerator = numerator;

}

/**

* @param denominator

* the denominator to set

*/

public nugatory setDenominator(int denominator) {

this.denominator = denominator;

}

/*

*

* @see java.lang.Object#toString()

*/

@Override

public String toString() {

requite “” + numerator + ” / ” + denominator;

}

}

public collocate Calculator {

private Participation fr1;

private Participation fr2;

/**

* @param fr1

* @param fr2

*/

public Calculator(Participation fr1, Participation fr2) {

this.fr1 = fr1;

this.fr2 = fr2;

}

/**

* @return

*/

int numerator = (fr1.getNumerator() * fr2.getDenominator())

+ (fr2.getNumerator() * fr1.getDenominator());

int denominator = fr1.getDenominator() * fr2.getDenominator();

requite upstart Participation(numerator, denominator);

}

/**

* @return

*/

public Participation subtFractions() {

int numerator = (fr1.getNumerator() * fr2.getDenominator())

– (fr2.getNumerator() * fr1.getDenominator());

int denominator = fr1.getDenominator() * fr2.getDenominator();

requite upstart Participation(numerator, denominator);

}

/**

* @return

*/

public Participation multFractions() {

Participation consequence = upstart Participation();

// count consequence

product.setNumerator(fr1.getNumerator() * fr2.getNumerator());

product.setDenominator(fr1.getDenominator() * fr2.getDenominator());

requite consequence;

}

/**

* @return

*/

public Participation divFractions() {

// invent upstart participation to requite as fruit

Participation fruit = upstart Participation();

// count fruit

result.numerator = fr1.numerator * fr2.denominator;

result.denominator = fr1.denominator * fr2.numerator;

requite fruit;

}

public int calcCommonDenominator() {

int M, N, R;

if (fr1.denominator < fr2.denominator) {

N = fr1.denominator;

M = fr2.denominator;

} else {

N = fr2.denominator;

M = fr1.denominator;

}

R = M % N;

while (R != 0) {

M = N;

N = R;

R = M % N;

}

requite N;

}

}

public collocate ArithmeticWithRefractory {

static Participation unite;

static Participation dissimilitude;

static Participation consequence;

static Participation quotient;

static Participation fr1 = upstart Participation();

static Participation fr2 = upstart Participation();

public static nugatory main(String[] args) {

String arg1[] = args.split(“/”);

String arg2[] = args.split(“/”);

fr1.setNumerator(Integer.parseInt(arg1));

fr1.setDenominator(Integer.parseInt(arg1));

fr2.setNumerator(Integer.parseInt(arg2));

fr2.setDenominator(Integer.parseInt(arg2));

Calculator calculator = upstart Calculator(fr1, fr2);

dissimilitude = calculator.subtFractions();

consequence = calculator.multFractions();

quotient = calculator.divFractions();

displayResults();

System.out.println(“The program was terminated”);

}

public static nugatory displayResults() {

System.out.println(“— Basic Operations with refractory —“);

System.out.println(fr1 + ” + ” + fr2 + ” = ” + unite);

System.out.println(fr1 + ” – ” + fr2 + ” = ” + dissimilitude);

System.out.println(fr1 + ” * ” + fr2 + ” = ” + consequence);

System.out.println(fr1 + ” / ” + fr2 + ” = ” + quotient);

}

}

OUTPUT:

java ArithmeticWithRefractory 2/5 1/7

— Basic Operations with refractory —
2 / 5 + 1 / 7 = 19 / 35
2 / 5 – 1 / 7 = 9 / 35
2 / 5 * 1 / 7 = 2 / 35
2 / 5 / 1 / 7 = 14 / 5
The program was terminated