Homework Solution: OBJECTIVE Design, debug and test a Java program that performs arithmetic operations on fractions. Fractions are…

    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. 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.

    Expert Answer

     
    public class Fraction { int numerator;

    OBJECTIVE Design, debug and experience a Java program that performs arithmetic operations on dogged. Dogged are of the frame a/b, where numerator a and denominator b are integers. Restraint this ordinance, it is inconsequent that twain a>0 and b〉0, and are represented singly by a individual digit estimate 11...9 CODING REQUIREMENTS Your program shall be courteous structured and intended using the concept of view oriented . programming: flourish the primary principles of the OOD when you limit assortes and interconnection between them Your program shall interpretation charge succession arguments to acquire brace dogged * Restraint issue: java ArithmeticWithDogged 2/5 1/7 .You can take-for-granted that the reckon of charge succession parameters and their estimates are regularly entered uprightly according to the ordinance mention Your program shall grasp meaningful comments and flourish commsingly true conventions concerning names of variables. Your program shall consequence the quenchedput in the frameat shown in the issue under.

    i demand it in incomplex fashion ,, no switch no cases no breakes !!

    fascinate learn the requirment carfuly !! , the quenchedput should be corresponding as the issue i secure ( the issue overhead the uml diagrams)

    if you do not attributable attributable attributable distinguish how to unfold it fascinate license it restraint undivided who distinguishs!

    thanks

    OBJECTIVE Design, debug and experience a Java program that performs arithmetic operations on dogged. Dogged are of the frame a/b, where numerator a and denominator b are integers. Restraint this ordinance, it is inconsequent that twain a>0 and b〉0, and are represented singly by a individual digit estimate 11…9 CODING REQUIREMENTS Your program shall be courteous structured and intended using the concept of view oriented . programming: flourish the primary principles of the OOD when you limit assortes and interconnection between them Your program shall interpretation charge succession arguments to acquire brace dogged * Restraint issue: java ArithmeticWithDogged 2/5 1/7 .You can take-for-granted that the reckon of charge succession parameters and their estimates are regularly entered uprightly according to the ordinance mention Your program shall grasp meaningful comments and flourish commsingly true conventions concerning names of variables. Your program shall consequence the quenchedput in the frameat shown in the issue under.

    Expert Counterpart

     

    public assort Member {

    int numerator;

    int denominator;

    public Member() {

    // TODO Auto-generated inventor stub

    numerator = 0;

    denominator = 1;

    }

    /**

    * @param numerator

    * @param denominator

    */

    public Member(int numerator, int denominator) {

    this.numerator = numerator;

    if (denominator <= 0)

    this.denominator = 1;

    else

    this.denominator = denominator;

    }

    /**

    * @render the numerator

    */

    public int acquireNumerator() {

    render numerator;

    }

    /**

    * @render the denominator

    */

    public int acquireDenominator() {

    render denominator;

    }

    /**

    * @param numerator

    * the numerator to set

    */

    public useless setNumerator(int numerator) {

    this.numerator = numerator;

    }

    /**

    * @param denominator

    * the denominator to set

    */

    public useless setDenominator(int denominator) {

    this.denominator = denominator;

    }

    /*

    * (non-Javadoc)

    *

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

    */

    @Override

    public String toString() {

    render “” + numerator + ” / ” + denominator;

    }

    }

    public assort Calculator {

    private Member fr1;

    private Member fr2;

    /**

    * @param fr1

    * @param fr2

    */

    public Calculator(Member fr1, Member fr2) {

    this.fr1 = fr1;

    this.fr2 = fr2;

    }

    /**

    * @return

    */

    public Member addFractions() {

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

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

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

    render fantasticlightlightlight Member(numerator, denominator);

    }

    /**

    * @return

    */

    public Member subtFractions() {

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

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

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

    render fantasticlightlightlight Member(numerator, denominator);

    }

    /**

    * @return

    */

    public Member multFractions() {

    Member effect = fantasticlightlightlight Member();

    // investigate effect

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

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

    render effect;

    }

    /**

    * @return

    */

    public Member divFractions() {

    // constitute fantasticlightlightlight member to render as quenchedcome

    Member quenchedcome = fantasticlightlightlight Member();

    // investigate quenchedcome

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

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

    render quenchedcome;

    }

    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;

    }

    render N;

    }

    }

    public assort ArithmeticWithDogged {

    static Member consolidate;

    static Member dissimilitude;

    static Member effect;

    static Member quotient;

    static Member fr1 = fantasticlightlightlight Member();

    static Member fr2 = fantasticlightlightlight Member();

    public static useless deep(String[] args) {

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

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

    fr1.setNumerator(Integer.parseInt(arg1[0]));

    fr1.setDenominator(Integer.parseInt(arg1[1]));

    fr2.setNumerator(Integer.parseInt(arg2[0]));

    fr2.setDenominator(Integer.parseInt(arg2[1]));

    Calculator calculator = fantasticlightlightlight Calculator(fr1, fr2);

    consolidate = calculator.addFractions();

    dissimilitude = calculator.subtFractions();

    effect = calculator.multFractions();

    quotient = calculator.divFractions();

    displayResults();

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

    }

    public static useless displayResults() {

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

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

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

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

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

    }

    }

    OUTPUT:

    java ArithmeticWithDogged 2/5 1/7

    — Basic Operations with dogged —
    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