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

. Create an application class whose main() method holds two numeric variables. P

ID: 3679836 • Letter: #

Question

. Create an application class whose main() method holds two numeric variables. Prompt the user for values for the variables. In a loop that continues while the returnded value is N, pass both variables to a method that determines whether the first number is larger then the second and appropriately returns a character Y or N. After the method returns Y, pass the two numbers to a method named difference() that computes the difference between its two parameters and displays the result.

CREATE a psuedocode for this question.

Explanation / Answer

import java.util.*;
import java.util.Scanner;

public class Application{

public static char max(Double x, Double y) {
if(x > y) return 'Y';
else return 'N';
}

public static Double difference(Double x, Double y) {
return x-y;
}

public static void main(String args[]){
  
Scanner sc = new Scanner(System.in);
char c ='Y';
while(true)
{
System.out.println();
System.out.println("Enter two numbers: ");
Double number1 = sc.nextDouble(); // taking the input
Double number2 = sc.nextDouble();

if(max(number1,number2) == 'Y') System.out.println("Difference between two numbers : "+ difference(number1,number2)); // calling the function
else {
System.out.println("Second Number is greater than the First");
break;
}
}
}
}