Computer Science, asked by suyashmomaya, 5 months ago

Write a program using statement to input two double type numbers and by using suitable mathematical function print the maximum and minimum values output of two numbers.

Answers

Answered by dattarajshinde44
1

Answer:

import java.util.*;

public class Question {

 public static void main(String[] agrs) {

   Scanner sc = new Scanner(System.in);

   System.out.println("Enter 2 Numbers");

   double a = sc.nextInt();

   double b = sc.nextInt();

   double c = Math.max(a,b);

   double d = Math.min(a,b);

   System.out.println("Max Number = "+c);

   System.out.println("Min Number = "+d);

}

}

Answered by anindyaadhikari13
2

Question:-

Write a program using statement to input two double type numbers and by using suitable mathematical function print the maximum and minimum values output of two numbers.

Program:-

There are two functions Math.max() and Math.min() which returns the largest and smallest of two numbers. Using these two methods, we will solve this program in Java.

So, here is the program.

import java.util.*;

class MaxMin

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.println("Enter two numbers...");

int a=sc.nextInt();

int b=sc.nextInt();

System.out.println("Largest Number is: "+Math.max(a, b));

System.out.println("Smallest Number is: "+Math.min(a, b));

}

}

Similar questions