Thursday 26 March 2020

FINDING SMALLER AMONG ALL USING JAVA LANGUAGE

Q-33-  If the ages of Rahul, Ayush and Ajay are input through the keyboard, write a java program to determine the elder among them.

INPUT :
import java.util.Scanner;
public class NCM {

public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int Rahul;
int Ayush;
int Ajay;
System.out.println("Enter The Ages Of Rahul ,Ayush And Ajay : ");
Rahul=sc.nextInt();
Ayush=sc.nextInt();
Ajay=sc.nextInt();
if(Rahul>Ayush && Rahul>Ajay)
{
System.out.println("Rahul Is Elder Among Them.");
}
else if(Ayush>Ajay && Ayush>Rahul)
{
System.out.println("Ayush Is Elder Among Them.");
}
else if(Ajay>Rahul && Ajay>Ayush)
{
System.out.println("Ajay Is Elder Among Them.");
}
}
}



OUTPUT :
Enter The Ages Of Rahul ,Ayush And Ajay :
16  15  17

Ajay Is Elder Among Them.

1 comment: