Q:

Write a Java Program to find Largest among three Numbers

belongs to collection: Java Basic Solved Programs

0

Input three number from user and compare these number with each others and find largest number among these three numbers.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

SOURCE CODE ::

import java.util.Scanner;
public class Largest 
{

    public static void main(String[] args) 
    {

        int a,b,c,largest;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter three numbers: ");
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();

            if(a>=b && a>=c) 
            {
                System.out.println("Largest number = "+a);
            }
            if(b>=a && b>=c) 
            {
                System.out.println("Largest number = "+b);
            }
            if(c>=a && c>=b) 
            {
                System.out.println("Largest number = "+c);
            }
    }
 }

OUTPUT ::

Enter three numbers: 
23
33
14
Largest number = 33

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java Basic Solved Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Write a Java Program to find given number is Palin... >>
<< Java Program to Check whether Given Number is Arms...