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

Write overloaded Java methods that return the difference of two parameters. Your

ID: 3623100 • Letter: W

Question

Write overloaded Java methods that return the difference of two parameters. Your methods should contain the logic to return the difference of the larger parameter – smaller parameter, regardless of parameter order. Provide enough test code to ensure your methods are logically correct. The following table displays the required method parameter variations. Each row indicates the return type, parameter 1 and parameter 2 for a separate method call using the pattern <return type> method_name(parm1 type, parm2 type);

Return Type

Parm 1 Type

Parm 2 Type

Int

int

int

double

double

double

double

int

double

double

double

int


Continue to properly document your source code.

Explanation / Answer

import java.util.*;

public class guess
{
    public static void main(String[] args) {
   System.out.println("Num 1 Num 2 Result" +sub(7,3) + sub(13.5,12.6) + sub(9.9, 3) + sub(6,2.9));

    }

public static int sub(int num1, int num2) {
return num1-num2;
}

public static double sub(double num1, double num2) {
return num1-num2;
}

public static double sub(int num1, double num2) {
return num1-num2;
}

public static double sub(double num1, int num2) {
return   (num1 - num2);
}



}


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