So i'm working on a revision tool that'll ask defined questions randomly using console command C#. I can create the random number but cannot seem to use the Switch function properly. Can anyone help?
// The random Object
Random Number = new Random();
while (true)
{
int Question = Number.Next(1);
Console.WriteLine("{0}", Question);
string Answer = Console.ReadLine();
if (Answer.ToLower() == "finished")
{
break;
}
if(Answer.Length == 0)
{
Console.WriteLine("Write Please");
continue;
}
switch (Question)
{
case 0:
{
Console.WriteLine("What is the nucleus of an atom made of");
if (Answer == "neutrons and protons")
{
Console.WriteLine("Well Done!");
}
if (Answer == "protons and neutrons")
{
Console.WriteLine("Well Done!");
}
Console.WriteLine("Try Again");
break;
}
}
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire