Question: This program needs to be written in C#. I have written this so far and I cannot figure out what parts are wrong or what
This program needs to be written in C#. 
I have written this so far and I cannot figure out what parts are wrong or what needs to be fixed.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace quizz
{
class Program
{
static void Main(string[] args)
{
//List to hold wrong answers
List
//Variable to hold result
int result = 0;
//Hold Total no of question default is 10
int QuestionSize=10;
//Flag to check for attempt
bool IsFirstAttempt=true;
//Array to hold question, Type(how many options), Options,Answer
// You can place your questions here
string[,] ques = new string[,] {
{ "In which year did the B-2 Spirit have its first flight?", "4", "1985", "1989", "1990", "1993", "2" }, { "There were only 21 B-2 Bombers ever made.", "2", "TRUE", "FALSE", "", "", "1" }, { "The length of the B-2 Spirit is how many feet?", "4", "85", "75", "69", "63", "3" }, { "The height of the B-2 Spirit is 17 feet.", "2", "TRUE", "FALSE", "", "", "1" }, { "The wingspan of the B-2 Spirit is how many feet?", "4", "172", "189", "195", "197", "1" }, { "The B-2 Stealth Bomber has four engines.", "2", "TRUE", "FALSE", "", "", "1" }, { "The B-2 Bomber has a maximum takeoff weight of how many lbs?", "4", "220,000 lbs", "300,000 lbs", "376,000 lbs", "450,000 lbs", "3" }, { "The B-2 Spirit can fly at Mach 0.95.", "2", "TRUE", "FALSE", "", "", "1" }, { "The B-2 Bomber has a flight ceiling of how many feet?", "4", "30,000", "40,000", "47,000", "50,000", "4" }, { "The B-2 Spirit can hold up to 50,000 lbs of payload in its two internal bays.", "2", "TRUE", "FALSE", "", "", "1" }, };
//Goto label for if there is second attempt
SecondAttempt:
//Loop continued to question size
for(int i=0;i { //make console clear Console.Clear(); //hold question no int qid; //if it is first attempt then continue question id as for loops i variable if (IsFirstAttempt) qid = i; else //else for second attemp go with wrong questions qid = wrong_ques.ElementAt(i); //Print question Console.WriteLine("Q." + (i + 1) + ": " + ques[qid,0]); //hold question type string qtype = ques[qid, 1]; //Hold answer of question string ans = ques[qid, 6]; //print options Console.WriteLine("1. " + ques[qid, 2]); Console.WriteLine("2. " + ques[qid, 3]); //if qtype is 4 then continue to print remaining options if (qtype == "4") { Console.WriteLine("3. " + ques[qid, 4]); Console.WriteLine("4. " + ques[qid, 5]); } //Get user answer Console.WriteLine("Enter Your Answer:"); string user_ans = Console.ReadLine(); //Match user answer with correct answer if (user_ans != ans) { //if it is first attemp and wrong answer then add that question to wrong //answer array list if (IsFirstAttempt) wrong_ques.Add(i); else { //else print correct answer Console.WriteLine("Sorry Correct answer is:" + ques[i, 6]); Console.ReadLine(); } } else //if answer is correct then increment result result++; } //if wrong_ques contains any wrong answer then make attempt for again one time only if(wrong_ques.Count>0 && IsFirstAttempt) { IsFirstAttempt = false; QuestionSize = wrong_ques.Count; Console.WriteLine("You have answered " + QuestionSize + " wrong answer press key to reattempt"); Console.ReadLine(); Console.Clear(); goto SecondAttempt; } else //print result Console.WriteLine("You Got " + result + " Out of 10 " ); Console.WriteLine("Press any key to exit...!"); Console.ReadLine(); } } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
