Computer Science, asked by jithinjoseph8067, 1 year ago

Write a program for fiend the max and min from the three numbers

Answers

Answered by sikhi
0

Answer:

package com.sample.sample2;

import java.util.Scanner;

public class Main {

   public static void main(String[] args) {

       Scanner scan=new Scanner(System.in);

       System.out.println("Enter number 1");

       int num1=scan.nextInt();

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

       int num2=scan.nextInt();

       System.out.println("Enter number 3");

       int num3=scan.nextInt();

       if(num1>num2&&num1>num3){

           System.out.println("Maximum:"+num1);

           if(num2<num3) System.out.println("minimum:"+num2);

           else System.out.println("minimum:"+num3);

       }

       if(num2>num1&&num2>num3){

           System.out.println("Maximum:"+num2);

           if(num1<num3) System.out.println("minimum:"+num1);

           else System.out.println("minimum:"+num3);

       }

       if(num3>num2&&num3>num1){

           System.out.println("Maximum:"+num1);

           if(num2<num1) System.out.println("minimum:"+num2);

           else System.out.println("minimum:"+num1);

       }

   }

}

Answered by anindyaadhikari13
1

Question:-

Write a program to find the max and min from three numbers.

Code:-

In Java.

class MaxMin

{

static void main(int a, int b, int c)

{

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

int min=Math.min(a, Math.min(b, c));

System.out.println("Max: "+max);

System.out.println("Min: "+min);

}

}

Similar questions