A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Java program to find largest number among three numbers
Q:

Java program to find largest number among three numbers

0

Find largest number from three integer number in Java: This program will read three integer number from the keyboard and find the largest number.

 

All Answers

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

Find largest among three numbers using Java Program

//Java program to find largest number among three numbers.
 
import java.util.*;
 
class LargestFrom3
{
    public static void main(String []s)
    {
        int a,b,c,largest;
        //Scanner class to read value
        Scanner sc=new Scanner(System.in);
         
        System.out.print("Enter first  number:");
        a=sc.nextInt();
        System.out.print("Enter second number:");
        b=sc.nextInt();
        System.out.print("Enter third  number:");
        c=sc.nextInt();
         
        if ( a>b && a>c )
            largest=a;
        else if ( b>a && b>c )
            largest=b;
        else
            largest=c;
         
        System.out.println("Largest Number is : "+largest);
         
    }
}

Output

    Complie 	:	javac LargestFrom3.java
    Run		:	java LargestFrom3
    Output
    Enter first  number:45
    Enter second number:56
    Enter third  number:67
    Largest Number is : 67

 

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now