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

importjava.util.Scanner; public class Test45 { public static void main(String[]

ID: 3614103 • Letter: I

Question

importjava.util.Scanner;

public class Test45 {
public static void main(String[] argv){

       // definevariables
       int a = 6;
       int b = 15;
       int option;
   
      // (1) invoke the method and displayresult
       option = getUserOption(a,b);
       System.out.println("Useroption is: " + option);

       // (2)invoke the method and display result
       option = getUserOption(b,a);
       System.out.println("Useroption is: " + option);

       // (3)invoke the method and display result
       option = getUserOption(a,a);
       System.out.println("Useroption is: " + option);

    }
    public static int getUserOption(int iVal1, intiVal2) {
// THE CODE GOES HERE
}

}


Explanation / Answer

please rate - thanks import java.util.Scanner; public class Test45{ public static void main(String[] argv){        // define variables        int a = 6;        int b = 15;        int option;       // (1) invoke the method and displayresult        option = getUserOption(a,b);        System.out.println("Useroption is: " + option);        // (2) invoke the method anddisplay result        option = getUserOption(b,a);        System.out.println("Useroption is: " + option);        // (3) invoke the method anddisplay result        option = getUserOption(a,a);        System.out.println("Useroption is: " + option);     }     public static int getUserOption(int iVal1, intiVal2) { // THE CODE GOES HERE Scanner in=new Scanner(System.in); int num,large,small; large=iVal1; if(iVal2>large)     {large=iVal2;    small=iVal1;    } else     small=iVal2; System.out.println("Enter a number between "+iVal1+" and"+iVal2); num=in.nextInt(); while(numlarge)    {System.out.println(num+" is not between "+iVal1+" and"+iVal2);     System.out.println("Enter a number between"+iVal1+" and "+iVal2);     num=in.nextInt();    } return num; } }