the problem is as follows:
Create a main class file. (1) Inside create a method max() that has two floating point
parameters x and y and returns the larger of x and y; (2) In the main method, input two
numbers from the keyboard, and then use the max() method you created to compute the
larger value and output it.
this is what I have so far but am confused on how to get my max method to return the larger sum
import java.util.Scanner; public class LargerNum { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter two values: "); double FirstNum = input.nextDouble(); double SecondNum = input.nextDouble(); double Final = MaxMethod(FirstNum, SecondNum); System.out.println(Final); } public static double MaxMethod(double L, double M){ double Temp = L; double TempTwo = M; double Large; if (Temp >= TempTwo); Large = Temp; if (TempTwo >=Temp); Large = TempTwo; return Large; }} I want the larger of the two to be assigned to Large but then how do i pass that back to the top so i can print it[COLOR="Silver"] --- Update --- [/COLOR]import java.util.Scanner; public class LargerNum { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("Enter two values: "); double FirstNum = input.nextDouble(); double SecondNum = input.nextDouble(); double Final = MaxMethod(FirstNum, SecondNum); } public static double MaxMethod(double L, double M){ double Temp = L; double TempTwo = M; double Large; if (Temp >= TempTwo){ Large = Temp;} else; Large = TempTwo; System.out.println(Large); return Large; }}
closer but not there yet please help the second number entered is printed needs to be the larger of the two
in output your asked to enter 2 numbers so say: 9 and 7, 7 will be returned whereas 9 should be returned