
It looks like you're new here. If you want to get involved, click one of these buttons!
string Answer = "";
string Option = "";
int score = 0;
int Tries = 0;
do
{
score = 0;
//Give the Instructions of this Quiz
Console.WriteLine("Multiple choice questions, select one answer in each question. Make sure your choice either A, B, C or D. (Note: You have 2 attempts, ATTEMPT:" + (Tries + 1));
// Display Question 1
Console.WriteLine("Question 1.) +2+2");
//Display all the Posible Choices
Console.WriteLine("A. 1");
Console.WriteLine("B. 2");
Console.WriteLine("C. 3");
Console.WriteLine("D. 4");
Console.WriteLine("Answer:");
Answer = Console.ReadLine().ToUpper(); //Read the Answer and Convert it to Upper Case
switch (Answer)
{
case "A":
break;
case "B":
break;
case "C":
score = score + 1; // Add +1 to the score if the Answer is correct
break;
case "D":
break;
default:
Console.WriteLine("You are wrong");
break;
}
//Display Question 2
Console.WriteLine("Question 2.) How many Fingers do you have in your hands");
//Display all the Posible Choices
Console.WriteLine("A. 10");
Console.WriteLine("B. 15");
Console.WriteLine("C. 20");
Console.WriteLine("D. 5");
Console.WriteLine("Answer:");
Answer = Console.ReadLine().ToUpper(); //Read the Answer and Convert it to Upper Case
switch (Answer)
{
case "A":
score = score + 1; // Add +1 to the score if the Answer is correct
break;
case "B":
break;
case "C":
break;
case "D":
break;
default:
Console.WriteLine("Nope");
break;
}
//Display Question 3
Console.WriteLine("Question 3.) what do you need to survive?");
//Display all the Posible Choices
Console.WriteLine("A. House");
Console.WriteLine("B. Water");
Console.WriteLine("C. Chocolate");
Console.WriteLine("D. Fruits");
Console.WriteLine("Answer:");
Answer = Console.ReadLine().ToUpper(); //Read the Answer and Convert it to Upper Case
switch (Answer)
{
case "A":
break;
case "B":
score = score + 1; // Add +1 to the score if the Answer is correct
break;
case "C":
break;
case "D":
break;
default:
Console.WriteLine("You are wrong");
break;
}
Console.WriteLine("Your score is" + (score / 3* 100) + "%");
Tries++; //Increment the No of Tries
Console.WriteLine("\nWould you like to try one more time? (Y/N):");
Option = Console.ReadLine().ToUpper();
if (Option != "Y")
break;
} while (Option != "N" && Tries <= 1);
}
}
But I would recommend creating a Question class, so that each question will have its own answer, score etc. Tell me if you have interest in this.
Answers
I will not go into your quiz but in what you need: