Discover the answers you need at Westonci.ca, a dynamic Q&A platform where knowledge is shared freely by a community of experts. Connect with professionals on our platform to receive accurate answers to your questions quickly and efficiently. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.
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);
Thanks for using our service. We aim to provide the most accurate answers for all your queries. Visit us again for more insights. Your visit means a lot to us. Don't hesitate to return for more reliable answers to any questions you may have. Thank you for visiting Westonci.ca. Stay informed by coming back for more detailed answers.