Menu
Question Index
...


Write a program to get the eldest Piscean from list of persons.
NOTE: While passing the month to the GregorianCalendar, it will start from 0 and go till 11.
Assume the Pisces range is [Feb 19–Mar 20]

Input (List) Output (String)
[Amir(1989-3-19), Rohith(1989-3-23), Rajini(1989-4-20), Krishna(1989-4-10), Jay(1989-3-17), Suma(1977-4-18)] Jay
[Mohan(1998-03-15), Rani(1956-04-20), Swetha(1947-03-19), Krishna(1987-02-23)] Swetha
[Lahari(1965-03-19), Jyothi(1988-03-21), Chaitanya(1978-03-20), Pavan(1964-02-19), Hemanth(1988-06-27), Krishna(1991-05-26)] Pavan
[Lahari(1987-04-11), Jyothi(1987-03-03), Chaitanya(1988-10-20), Pavan(1988-10-23), Akhil(1988-03-21), Sowjanya(1968-10-26)] Jyothi
[Lahari(1999-11-30), Jyothi(1988-11-30), Chaitanya(1988-08-20), Pavan(1991-04-19), Akhil(1990-03-20), Sowjanya(1990-04-11)] Akhil

class IdentifyTheEldestPiscean

{    public static void main(String s[])
    {
        ArrayList list = new ArrayList();
        list.add(new Person("Amir", new GregorianCalendar(1989, 2, 19)));
        list.add(new Person("Rohith", new GregorianCalendar(1989, 2, 23)));
        list.add(new Person("Rajini", new GregorianCalendar(1989, 3, 20)));
        list.add(new Person("Krishna", new GregorianCalendar(1989, 3, 10)));
        list.add(new Person("Jay", new GregorianCalendar(1989, 2, 17)));
        list.add(new Person("Suma", new GregorianCalendar(1977, 3, 18)));
        System.out.println("The eldest Piscean is " + getEldestPiscean(list));

    }


public static String getEldestPiscean(ArrayList<Person> input) {
//Write code here to get the eldest piscean
}
}
class Person {

String name;
Calendar dateOfBirth;

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

@Override
public String toString() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
return name + "(" + sdf.format(dateOfBirth.getTime()) + ")";
}
}

Doubts

Problems

Topic: Locale Class In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App