info@meritcampus.com    +91-85006-22255
...

Write a program to get the number of pairs which can be formed such that the man is elder than woman.

Input (List, List) Output (Integer)
[Krishna-18, Ram-25, Arun-22, Sunil-27, Shankar-33] and [Mounika-18, Madhu-20, Archana-22, Anusha-25, Kavya-27] 14
[Jay-3, Chaitanya-15, Arjun-3] and [Padma-2, Sandhya-12, Chitra-3] 5
[Sunil-24, Anand-25, Suman-27, Chanti-30, Jayanth-35, Gopi-37] and [Jyothi-19, Bindu-17, Sindu-16, Hema-18, Anjali-20, Madhu-23] 36
[Sunil-24, Anand-25, Suman-27, Chanti-30, Jayanth-35] and [Jyothi-19, Bindu-17, Sindu-27, Hema-18, Anjali-24] 21
[Abhishek-10, Vinod-27, Sai-23, Chandra-19] and [Aiswarya-33, Bindu-45, Sindu-30, Hema-27] 0

import java.util.*;
class ManElderThanWoman
{
public static void main(String s[])
{
ArrayList<Person> men = new ArrayList<Person>();
ArrayList<Person> women = new ArrayList<Person>();
System.out.println("Number of pairs in which man is elder than woman : " + pairMenAndWomen(men, women));

}

private static int pairMenAndWomen(List<Person> men, List<Person> women) {
}

}
class Person {

String name;
int age;

Person(String name, int age) {
this.name = name;
this.age = age;
}

@Override
public String toString() {
return name + "-" + age;
}
}

Topic: Java ArrayList

0
Wrong
Score more than 2 points