Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Provide the output for the following program AND PLEASE EXPLAIN LIKE I AM A KID!

ID: 3813054 • Letter: P

Question

Provide the output for the following program AND PLEASE EXPLAIN LIKE I AM A KID!!

   public class testCase{

    public static void main (String [] args) {

        PT tester = new PT ();

        int a1 = 13;

        Fraction a2 = new Fraction (1,2);

        Fraction a3 = new Fraction (1,4);

       

        System.out.println ("Print1 a1=" + a1 + "a2=" + a2 + "a3=" + a3);

        tester.eV(a1,a2,a3);

        System.out.println ("Print4 a1=" + a1 + "a2=" + a2 + "a3=" + a3);

       

    }

}

public class PT{

    public void cV (int v1, Fraction v2, Fraction v3) {

        System.out.println ("On entry:");

        System.out.println ("Print2 v1=" + v1 + "v2=" +v2 + "v3=" + v3);

        v1 = 5;

        v2.sD (10);

        v3 = new Fraction (3,4);

        System.out.println ("On exit:");

        System.out.println ("Print 3 v1 =" + v1 + "v2=" + v2 + "v3=" + v3);

       

    }

}

public class Fraction {

    private int denominator;

    private int numerator;

    public Fraction (int num,int denom) {

        numerator = num;

        denominator = denom;

    }

   

    public void sD (int value) {

        denominator = value;

    }

   

    /**

     * toString returns the string value of Fraction

     * and is automatically invoked when needing a string value for

     * an instance of type Num

     */

    public String toString () {

        return numerator + "/" + denominator;

    }

}

Explanation / Answer

out put will be.

Print1 a1=13a2=1/2a3=1/4
On entry:
Print2 v1=13v2=1/2v3=1/4
On exit:
Print 3 v1 =5v2=1/10v3=3/4
Print4 a1=13a2=1/10a3=1/4

explaination

public class testCase{

    public static void main (String [] args) {

        PT tester = new PT ();// create a new instance of the class

        int a1 = 13;

        Fraction a2 = new Fraction (1,2);// devide the 1 by 2

        Fraction a3 = new Fraction (1,4);// devide the 1 by 4

       

        System.out.println ("Print1 a1=" + a1 + "a2=" + a2 + "a3=" + a3);

        tester.cV(a1,a2,a3);// i have changed from ev to cV because there were no method called eV

        System.out.println ("Print4 a1=" + a1 + "a2=" + a2 + "a3=" + a3);//this should out put Print4 a1=13a2=1/10a3=1/4

     

    }

}

Please let me know if you need further explaination

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote