Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a program in C# that has 2 multiple choice questions. ALL the following r

ID: 3847260 • Letter: C

Question

Create a program in C# that has 2 multiple choice questions.

ALL the following requirements must be included.

1. Users have two attempts only, show attempt number each time. Use while loop with break control.

2. Only one correct answer for each question, use switch case for each question.

3. Show total score after the two questions are answered. Use if...else if...else.

4. User have options to answer the two questions again if first attempt score is not 100%. Use if statement.

5. Use string method .ToUpper() to allow users to enter with lowercase or uppercase letters for the answers.

There are the examples of the outputs.

-------------------------------------------------Output Scenario 1------------------------------------------------------

Multiple choice questions, select one answer in each question. (Note: You have 2 attempts, attempt 1)

1. Where is the capital of France?
   A. London
   B. Madrid
   C. Paris
   D. Rome

Answer: __d__   Wrong user input. Upper or lower case letter allowed.

2. Where is Spain located?
   A. Asia
   B. Europe
   C. Africa
   D. South America
                    
Answer: __d__       Wrong user input. Upper or lower case letter allowed.

Your Score is: 0%  

Would you like to try one more time? (Y/N): __n___      User input ‘n’ to end program. Upper or   lower case letter allowed.

Press any key to continue…      Program ends only if ‘n’ is selected

Or…

Would you like to try one more time? (Y/N): __y__      User input ‘y’ to continue with second attempt. Upper or lower case letter allowed

Multiple choice questions, select one answer in each question. (Note: You have 2 attempts, attempt 2)

1. Where is the capital of France?
   A. London
   B. Madrid
   C. Paris
   D. Rome

Answer: __A__   Wrong user input. Upper or lower case letter allowed

2. Where is Spain located?
   A. Asia
   B. Europe
   C. Africa
   D. South America
                    
Answer: __D__       Wrong user input. Upper or lower case letter allowed.

Your Score is: 0%  

Press any key to continue… Program automatically ends here

-----------------------------------------------Output Scenario 2-------------------------------------------------------------

Multiple choice questions, select one answer in each question. (Note: You have 2 attempts, attempt 1)

1. Where is the capital of France?
   A. London
   B. Madrid
   C. Paris
   D. Rome

Answer: __c__   Right user input. Upper or lower case letter allowed.

2. Where is Spain located?
   A. Asia
   B. Europe
   C. Africa
   D. South America
                    
Answer: __D__       Wrong user input. Upper or lower case letter allowed.

Your Score is: 50%

Would you like to try one more time? (Y/N): __N___      User input ‘n’ to end program. Upper or lower case letter allowed.

Press any key to continue…      Program ends only if ‘n’ is selected

Or…

Would you like to try one more time? (Y/N): __y__      User input ‘y’ to continue with second attempt. Upper or lower case letter allowed.

Multiple choice questions, select one answer in each question. (Note: You have 2 attempts, attempt 2)

1. Where is the capital of France?
   A. London
   B. Madrid
   C. Paris
   D. Rome

Answer: __c__   Right user input. Upper or lower case letter allowed.

2. Where is Spain located?
   A. Asia
   B. Europe
   C. Africa
   D. South America
                    
Answer: __B__       Right user input. Upper or lower case letter allowed.

Your Score is: 100%

Press any key to continue… Program automatically ends here

Explanation / Answer

using System.IO;
using System;
namespace StringApplication
{
class Program
{
public int Q1()
{
string option;
Console.WriteLine("1. Where is the capital of France?");
Console.WriteLine("A. London");
Console.WriteLine("B. Madrid");
Console.WriteLine("C. Paris");
Console.WriteLine("D. Rome");
option=Console.ReadLine();

switch(option)
{
case "A":
Console.WriteLine("Wrong Answer!! try again");
return 1;
break;
  
case "B":
Console.WriteLine("Wrong Answer!! try again");
return 1;
break;
  
case "C":
Console.WriteLine("Correct Answer!! Well done");
return 0;
break;
  
case "D":
Console.WriteLine("Wrong Answer!! try again");
return 1;
break;
default:
Console.WriteLine("Invalid grade");
return 1;

}
  
  
}
  
public int Q2()
{string option1;
Console.WriteLine("2. Where is Spain located?");
Console.WriteLine("A.Asia");
Console.WriteLine("B.Europe");
Console.WriteLine("C.Africa");
Console.WriteLine("D.South America");
option1=Console.ReadLine();
switch(option1)
{
case "A":
Console.WriteLine("Wrong Answer!! try again");
return 1;
break;
  
case "B":
Console.WriteLine("Correct Answer!! Well done");
return 0;
break;
  
case "C":
Console.WriteLine("Wrong Answer!! try again");
return 1;
break;
  
case "D":
Console.WriteLine("Wrong Answer!! try again");
return 1;
break;
default:
Console.WriteLine("Invalid grade");
return 1;
break;
  
}
  
}
  
static void Main()
{
int a=0,b=0;
String choice;
Program c=new Program();


while(true)
{
int count = 1, sum = 0;
while(true)
{
a=c.Q1();
if(a == 0)
   sum = sum + 1;
b=c.Q2();
if(b == 0)
   sum = sum + 1;

count = count + 1;

if(count == 2)
break;
  
}
if(sum == 2)
   Console.WriteLine("Your Score is: 100%");
else if(sum == 1)
   Console.WriteLine("Your Score is: 50%");
else
   Console.WriteLine("Your Score is: 0%");
  
Console.WriteLine("Do you wish to continue");
choice=Console.ReadLine();

if(choice=="n" || choice=="N");
break;
}
  
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote