- import java.util.*;
- import java.io.*;
- import java.util.Map.*;
- class Main{
- public static void main(String args[]){
- Scanner sc=new Scanner(System.in);
- System.out.println("Enter the number of passengers in First friday flight from Chennai to Coimbatore");
- int n1=sc.nextInt();
- sc.nextLine();
- System.out.println("Enter the passengers Names");
- ArrayList<String> l1=new ArrayList<>();
- for(int i=0;i<n1;i++){
- l1.add(sc.nextLine());
- }
- System.out.println("Enter the number of passengers in Second friday flight from Chennai to Coimbatore");
- int n2=sc.nextInt();
- sc.nextLine();
- System.out.println("Enter the passengers Names");
- ArrayList<String> l2=new ArrayList<>();
- for(int i=0;i<n2;i++){
- l2.add(sc.nextLine());
- }
- System.out.println("Enter the number of passengers in third friday flight from Chennai to Coimbatore");
- int n3=sc.nextInt();
- sc.nextLine();
- System.out.println("Enter the passengers Names");
- ArrayList<String> l3=new ArrayList<>();
- for(int i=0;i<n3;i++){
- l3.add(sc.nextLine());
- }
- Map<String,Integer> map=new HashMap<>();
- for(String s: l1 ){
- map.put(s,map.getOrDefault(s,0)+1);
- }
- for(String s: l2 ){
- map.put(s,map.getOrDefault(s,0)+1);
- }
- for(String s: l3 ){
- map.put(s,map.getOrDefault(s,0)+1);
- }
- System.out.println("Selected passengers for discount:");
- for(Entry<String, Integer> entry: map.entrySet()) {
- if(entry.getValue()==3){
- System.out.println( entry.getKey() );
- }
- }
- }
- }
[text] l1
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: