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

Java Question. Create an application named Numbers whose main() method holds two

ID: 645306 • Letter: J

Question

Java Question.

Create an application named Numbers whose main() method holds two integer variables. Assign values to the variables. Pass both values to methods named sum() and difference(). Create the methods sum() and difference(); then compute the sum and difference between the values of two arguments, respectively. Each method should perform the appropriate computation and display the results. Save the application as Numbers.java.

Please let me know what IDE was used and will run.

Explanation / Answer

public class Numbers { public static void main(String[] args) { int valOne = 20; int valTwo = 37; Numbers num = new Numbers(); num.sum(valOne, valTwo); num.difference(valOne, valTwo); } private void sum(int i, int j) { System.out.println("Sum of " + i + " and " + j + " = " + (i + j)); } private void difference(int i, int j) { int diff = 0; if(i >= j) { diff = i - j; } else { diff = j - i; } System.out.println("Difference of " + i + " and " + j + " = " + diff); } }

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