Having some issues with for loops.

So I need this to print "The Name Game" followed by all of those lyrics for the names chosen. I currently have a working build shown below that prompts the users for the name each time and gives off the right information but separately. I'm not sure where I should put a for loop or if I even need to. Any idea how to get them to show up together?

string letter, restofname, names; int amountofnames;

 Console.WriteLine("How many names would you like to use?"); names = Console.ReadLine(); amountofnames = Convert.ToInt32(names); for (int i=1;i<=amountofnames;i++) { string name; Console.WriteLine("What name would you like to use?(please capitalize the first letter.)"); name = Console.ReadLine(); letter = name.Substring(0,1); restofname = name.Substring(1); Console.WriteLine("The Name Game"); switch (letter) { //Cases for vowels case "A": case "E": case "I": case"O": case"U": case "Y": Console.WriteLine(name + "!"); Console.WriteLine(name + "," + name + "," + "bo-b" + restofname); Console.WriteLine("Banana-fana fo-f" + restofname); Console.WriteLine("Fee-fi-mo-m" + restofname + "\n" + name+"\n"); break; //Cases for B,F,M case "B": case"F": case"M": Console.WriteLine(name + "!"); Console.WriteLine(name + "," + name + "," + "bo-"+letter + restofname); Console.WriteLine("Banana-fana fo-" +letter+ restofname); Console.WriteLine("Fee-fi-mo-" +letter+ restofname + "\n" + name+"\n"); break; //Cases for consonants excluding B,F,M case "C":case "G":case "H":case "J":case "K":case "L":case "P": case "Q":case "R": case "S": case "T":case "V":case "W":case "X": case "Z": Console.WriteLine(name + "!"); Console.WriteLine(name + "," + name + "," + "bo-b" + restofname); Console.WriteLine("Banana-fana fo-f" + restofname); Console.WriteLine("Fee-fi-mo-m" + restofname + "\n" + name+"\n"); break; 

by Operationroobaloo via /r/csharp

Leave a Reply