Computer Science, asked by nishantjune34, 1 month ago

Write a program (In Java) to input three numbers and print the largest among them.​

Answers

Answered by DeepakUgalePatil
3

Answer:

public class Biggest_Number

{

public static void main(String[] args)

{

int x=200, y=40, z=500;

if(x > y && x > z)

{

System.out.println("Largest number is:"+x);

}

else if(y > z)

{

System.out.println("Largest number is:"+y);

}

else

{

System.out.println("Largest number is:"+z);

}

}

}

output:

Largest number is:500

Answered by atrs7391
5

package com.company.B;

import java.util.Scanner;

public class inAnswer {

   public static void main(String[] args) {

       Scanner sc  = new Scanner (System.in);

       System.out.println("Enter 1st Number");

       double n1 = sc.nextDouble();

       System.out.println("Enter 2nd Number");

       double n2 = sc.nextDouble();

       System.out.println("Enter 3rd Number");

       double n3 = sc.nextDouble();

       if (n1 >= n2 && n1 >= n3)

           System.out.println( n1 + " is the greatest number.");

       else if (n2 >= n1 && n2 >= n3)

           System.out.println( n2 + " is the greatest number.");

       else

           System.out.println( n3 + " is the greatest number.");

   }

}

Similar questions