I'm attempting to loop through a switch in C# for a simple console application that returns data based on user input. I am new to coding. I know that the Switch works as I tested it before trying to implement my loop. But when I add the code for loop to my program I cannot get it to provide the data.
I tried taking the switch out completely and using independent If statements for each "case" but this was not working either. I'd really like to see the switch work in the loop if it's possible.
static void Main(string[] args)
{
var repeat = true;
while(repeat)
{
Console.WriteLine("Hello. Which instrument would you like to review? Type Quit to exit the program.");
string instruments = Console.ReadLine();
var action = Console.ReadLine();
if (action == instruments)
{
switch (instruments)
{
case "Jazzmaster":
string jazzmasterMake = "Fender";
string jazzmasterModel = "Jazzmaster";
string jazzmasterType = "guitar";
string jazzmasterCountry = "Japan";
int jazzmasterYear = 1997;
string jazzmasterSerial = "A019459";
string jazzmasterColor = "Sunburst";
{
Console.WriteLine("Your " + jazzmasterMake + " " + jazzmasterModel + " is a " + jazzmasterType + " made in " + jazzmasterCountry
+ " in " + jazzmasterYear + " in a " + jazzmasterColor + " color and with a serial number of " + jazzmasterSerial + ".");
}
break;
case "Jaguar":
string jaguarMake = "Fender";
string jaguarModel = "Jaguar";
string jaguarType = "guitar";
string jaguarCountry = "Japan";
int jaguarYear = 1997;
string jaguarSerial = "A035931";
string jaguarColor = "White";
{
Console.WriteLine("Your " + jaguarMake + " " + jaguarModel + " is a " + jaguarType + " made in " + jaguarCountry
+ " in " + jaguarYear + " in a " + jaguarColor + " color and with a serial number of " + jaguarSerial + ".");
}
break;
case "Stratocaster":
string stratocasterMake = "Fender";
string stratocasterModel = "Stratocaster";
string stratocasterType = "guitar";
string stratocasterCounty = "USA";
int stratocasterYear = 2018;
string stratocasterSerial = "US18004688";
string stratocasterColor = "Black";
{
Console.WriteLine("Your " + stratocasterMake + " " + stratocasterModel + " is a " + stratocasterType + " made in " + stratocasterCounty
+ " in " + stratocasterYear + " in a " + stratocasterColor + " color and with a serial number of " + stratocasterSerial + ".");
}
break;
default:
Console.WriteLine("That instrument is not in your collection.");
break;
}
}
else if (action == "Quit")
{
repeat = false;
}
}
}
}
}