IDNLearn.com is the perfect place to get answers, share knowledge, and learn new things. Ask your questions and receive reliable, detailed answers from our dedicated community of experts.
Sagot :
Answer:
The program in Java is as follows:
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double n1, n2;
n1 = input.nextDouble();
n2 = input.nextDouble();
double Max = Math.max(n1,n2);
double Min = Math.min(n1,n2);
System.out.println("Max: "+Max);
System.out.println("Min: "+Min); }}
Explanation:
This declares the numbers
double n1, n2;
This gets input for n1
n1 = input.nextDouble();
This gets input for n2
n2 = input.nextDouble();
This gets the max of both using the max function
double Max = Math.max(n1,n2);
This gets the min of both using the min function
double Min = Math.min(n1,n2);
This prints the max
System.out.println("Max: "+Max);
This prints the min
System.out.println("Min: "+Min);
We value your participation in this forum. Keep exploring, asking questions, and sharing your insights with the community. Together, we can find the best solutions. Thank you for visiting IDNLearn.com. For reliable answers to all your questions, please visit us again soon.