Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a program that takes two integer inputs, and outputs the largest magnitude value.Ex: If the inputs are:5 7the method returns:7Ex: If the inputs are:-8 -2the method returns:-8Note: The method does not just return the largest value, which for -8 -2 would be -2. Though not necessary, you may use the absolute-value built-in math method.Your program must define and call a method:public static int maxMagnitude(int userVal1, int userVal2)What I have so far:import java.util.Scanner;public class LabProgram {/* Define your method here */public static void main(String[] args) {/* Type your code here */}

Respuesta :

Answer:

See the code snippet below

Explanation:

import java.util.Scanner;

public class LabProgram{

     public static void main(String[] args){

          Scanner scan = new Scanner(System.in);

          System.out.println("Please enter first number: ");

          int firstNumber = scan.nextInt();

          System.out.println("Please enter second number: ");

          int secondNumber = scan.nextInt();

          maxMagnitude(firstNumber, secondNumber);

}

     public static int maxMagnitude(int firstValue, secondValue){

         System.out.println(Math.max(firstValue, secondValue));

}

}