AddNewMember – Hands- On C# Cognizant Solution
The LakeView Club have list of members under specific groups .
Write a program that add new members in the group available.
There are three groups 1- Gold  2- Silver 3- Platinum .
Get the group input and member name from the user .
Add the particular member to that specified group and display all the member under that group.
Use the Collection concepts to implement . Â
Sample Input1 :
Group Name :
Silver
Member Name:
Rahul
Sample Output1:
Sam
Peter
Rahul
Sample Input2 :
Group Name :
Gold
Member Name:
Helen
Sample Output2:
Tom
Harry
Helen
Club.cs
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AddNewMember //Do not change the namespace name { public class Club //Do not change the class name { static Dictionary<int, string> groupInfo = new Dictionary<int, string>() { { 1, "Gold" }, { 2, "Silver" }, { 3, "Platinum" } }; static Dictionary<int, List<String>> memberInfo = new Dictionary<int, List<String>>() { { 1, new List<string>(){ "Tom","Harry"} }, { 2,new List<string>(){ "Sam","Peter"} }, { 3,new List<string>(){ "Kim","Robert"} } }; public static void Main(string[] args) //Do not change the method signature { List<string> gold = memberInfo[1]; List<string> silver = memberInfo[2]; List<string> platinum = memberInfo[3]; Console.WriteLine("Group Name :"); string groupName = Console.ReadLine(); Console.WriteLine("Member Name :"); string memberName = Console.ReadLine(); if(groupName == "Gold" || groupName == "gold") { gold.Add(memberName); foreach(string goldGroup in gold) Console.WriteLine(goldGroup); } if(groupName == "Silver" || groupName == "silver") { silver.Add(memberName); foreach(string silverGroup in silver) Console.WriteLine(silverGroup); } if(groupName == "Platinum" || groupName == "platinum") { platinum.Add(memberName); foreach(string platinumGroup in platinum) Console.WriteLine(platinumGroup); } } } }