Multiple Choice Project
CSharp Programming **The code must look like the screenshot and have the same spacing.**
Create a program with two multiple choice questions.
1. Users have two attempts only, show attempt number each time. Hint: while loop with break control. (20%)
2. Only one correct answer for each question, use switch case for each question. (20%)
3. Show total score after the two questions are answered. Hint: if…else if…else. (20%)
4. User have options to answer the two questions again if first attempt score is not 100%. Hint: if statment. (20%)
5. Use string method .ToUpper() to allow users to enter with lowercase or uppercase letters. (20%)
1. Where is the capital of the state of Florida?
A. Orlando
B. Tallahassee
C. Miami
D. Tampa
Answer: B
2. Where is Walt Disney World Park located in Florida?
A. Orlando
B. Tallahassee
C. Miami
D. Tampa
Answer: a
Expert Answer
using System.IO;
using System;
namespace StringApplication
{
class Program
{
public int Q1()
{
string option;
Console.WriteLine(“1. Where is the capital of the state of Florida?”);
Console.WriteLine(“A. Orlando”);
Console.WriteLine(“B. Tallahassee”);
Console.WriteLine(“C. Miami”);
Console.WriteLine(“D. Tampa”);
option=Console.ReadLine();
switch(option)
{
case “A”:
Console.WriteLine(“Wrong Answer!! try again”);
return 1;
break;
case “B”:
Console.WriteLine(“Correct Answer!! Well done”);
return 1;
break;
case “C”:
Console.WriteLine(“Wrong Answer!! try again”);
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 Walt Disney World Park located in Florida?”);
onsole.WriteLine(“A. Orlando”);
Console.WriteLine(“B. Tallahassee”);
Console.WriteLine(“C. Miami”);
Console.WriteLine(“D. Tampa”);
option1=Console.ReadLine();
switch(option1)
{
case “A”:
Console.WriteLine(“Correct Answer!! Well done”);
return 1;
break;
case “B”:
Console.WriteLine(“Wrong Answer!! try again”);
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;
}
}
}
}