Greatest of three numbers using else if conditions

 Greatest of three numbers using else if  conditions




PROGRAM:


import java.util.*;
class elseif
{
    public static void main(String args[])
    {
        Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();//5
        int b=sc.nextInt();//7
        int c=sc.nextInt();//2
        if(a>b && a>c)
        {
            System.out.println("A is greatest");
        }
        else if(b>a && b>c)//7>5 && 7>2
        {
            System.out.println("B is greatest");
        }
        else{
            System.out.println("C is greatest");
        }
    }
}

// 5
// 6
// 7
// C is greatest

Comments

Popular posts from this blog

PROGRAM TO FIND FACTORIAL OF A NUMBER USING RECURSION

PROGRAM TO FIND THE COUNT OF PARTICULAR NUMBER IN AN ARRAY

TELEPHONE BOOK USING HASHMAP