Menu
Question Index
...


Write a program to get the youngest libran from the list of persons.
NOTE: While passing the month to the GregorianCalendar, it will start from 0 and go till 11.
Assume that the Libra range is [Sept 23–Oct 22]

Input (List) Output (String)
[Amir(1989-06-25), Rohith(1989-10-25), Rajini(1989-10-23), Krishna(1989-11-10), Jay(1989-09-23), Suma(1977-10-27)] Jay
[Mohan(1947-11-15), Rani(1956-11-20), Swetha(1998-10-22), Krishna(1987-09-23)] Swetha
[Rani(1936-10-20),  Kumar(1999-11-01), Padma(1988-10-22), Sandhya(1988-11-01) ] Padma
[Lahari(1965-11-21), Jyothi(1988-09-23), Chaitanya(1978-09-20), Pavan(1964-01-18), Hemanth(1988-03-27), Krishna(1991-04-26)] Jyothi
[Lahari(1978-11-30), Jyothi(1988-11-30), Chaitanya(1988-08-20), Pavan(1990-10-25), Akhil(1990-10-07), Sowjanya(1966-09-17)] Akhil

class IdentifyTheYoungestLibran

{    public static void main(String s[])
    {
        ArrayList list = new ArrayList();
        list.add(new Person("Amir", new GregorianCalendar(1989, 5, 25)));
        list.add(new Person("Rohith", new GregorianCalendar(1989, 9, 25)));
        list.add(new Person("Rajini", new GregorianCalendar(1989, 9, 23)));
        list.add(new Person("Krishna", new GregorianCalendar(1989, 10, 10)));
        list.add(new Person("Jay", new GregorianCalendar(1989, 8, 23)));
        list.add(new Person("Suma", new GregorianCalendar(1977, 9, 27)));
        System.out.println("The youngest libran is " + getTheYoungestLibran(list));

    }


public static String getTheYoungestLibran(ArrayList<Person> input) {
//Write code here to get the youngest libran and return it.
}
}
class Person {

String name;
Calendar dateOfBirth;

public Person(String name, Calendar dateOfBirth) {
this.name = name;
this.dateOfBirth = dateOfBirth;
}
}

Doubts

Problems

Topic: Java GregorianCalendar

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App