Menu
Question Index
...


Write a program to get the number of friends of a given person.

Input (String, String) (For display purpose new line is shown as $) Output (int)
Ravi,Lokesh$Ravi,venkatesh$Ravi,Swetha$Swetha,Narayan$Narayan,Lakshmi$Lakshmi,Divya$Divya,Narayan$Ram,Divya$Sanjay,Ravi$Lokesh,Sanjay
personName is Ravi
4
Raju,Rani$Raju,Vikram$Raju,Abhijeet$Abhijeet,Rajesh$Rajesh,Saranya$Saranya,Tejaswini$Tejaswini,Manish$Saranya,Ramana$Ramana,Raju$Tejaswini,Rani
personName is Tejaswini
3
Raju,Rani$Raju,Vikram$Raju,Abhijeet$Abhijeet,Rajesh$Rajesh,Saranya$Saranya,Tejaswini$Tejaswini,Manish$Saranya,Ramana$Ramana,Raju$Tejaswini,Rani
personName is Mahesh
0

class GetNumberOfFriendsOfPerson

{    public static void main(String s[])
    {
        String input = "Raju,Rani\nRaju,Vikram\nRaju,Abhijeet\nAbhijeet,Rajesh\nRajesh,Saranya\nSaranya,Tejaswini\nTejaswini,Manish\nSaranya,Ramana\nRamana,Raju\nTejaswini,Rani";
        System.out.println("The number of friends of Rani are " + getNumberOfFriends(input, "Rani"));

    }


public static int getNumberOfFriends(String friendsDetails, String personName) {
//Write code here to get the number of friends of a given person.
}
}

Doubts

Problems

Topic: Java String Arrays - String Arrays 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