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

Good Morning, Please help I am writing a code in C#. I need the incorrect answer

ID: 3742601 • Letter: G

Question

Good Morning,

Please help I am writing a code in C#. I need the incorrect answers to loop and to implement a method. And if possible eliminate the Console.WriteLine() . I also need the scores to tally for the correct answers and show at the end of the loop. Any guidance in this would be much appreciated please see the code that I have so far attached below.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ENGR115projectMcDowell
{
class WriteLine
{

static void Main(string[] args)
{ // introduction.
string PersonalName = "Matthew McDowell";
string ProjectName = "ENGR 115 Course Project";
string Dates = "Aug-Oct 2018";
//print personal data to screen.
{
Console.WriteLine("Welcome to the project for " + PersonalName);
Console.WriteLine(ProjectName);
Console.WriteLine(Dates);
Console.ReadKey();
{
// this section will expalin the peramiters of the test
}
string directions = "This quiz is made up of 10 questions combination of True/False statements, and multiple choice questions. If you are correct you will not need to repeat the question. If you are wrong you will be required to repeat the question later. ADDItiONAL INFORMATION User must hit space bar once then answer enter answer as = a,b,c,true,false.";//if not the system will state the answer given is wrong.
Console.WriteLine(directions);
Console.ReadKey();
string Start = "Lets Begin";
Console.WriteLine(Start);
Console.ReadKey();
}
//Answer Key
string A1 = "true";
string A2 = "false";
string A3 = "a";
string A4 = "b";
string A5 = "c";
string Repeat = "If you did not get 100 please relpeat exam";
int CorrectAnswers = 0;
for (; ; )
{
Console.WriteLine();
Console.WriteLine();

///Here we will begin the quiz

const string V1 = "Q1. What does the symbole Vr indicate?";
Console.WriteLine(V1);
string answerchoices = "a.Rotation b.Best angle of climb c.Best rate of climb";
Console.WriteLine(answerchoices);
Console.ReadKey();
string userInput1 = Console.ReadLine();
if (userInput1 == A3)
{
if (userInput1 == A3) Console.WriteLine("correct");
CorrectAnswers++;
}
else { Console.WriteLine("incorrect answer is {0}", A3); }


Console.WriteLine();
Console.WriteLine();
//
string V2 = "Q2. Va is the maximum allowable structural speed for full defection of control surfaces on an aircraft";
Console.WriteLine(V2);
string answerchoicesV2 = "true false";
Console.WriteLine(answerchoicesV2); Console.ReadKey();
string userInput2 = Console.ReadLine();
if (userInput2 == A1)
{
Console.WriteLine("correct");
CorrectAnswers++;
}
else { Console.WriteLine("incorrect answer is {0}", A1); }

Console.WriteLine();
Console.WriteLine();
Console.WriteLine();
//
const string V3 = "Q3. Vso is the velocity of stall speed for an aircraft.";
Console.WriteLine(V3);
string answerchoicesV3 = "true false";
Console.WriteLine(answerchoicesV3); Console.ReadKey();
string userInput3 = Console.ReadLine();
if (userInput3 == A1)
{
Console.WriteLine("correct");
CorrectAnswers++;
}
else
{
Console.WriteLine("incorrect answer is {0}", A1);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();

const string V4 = "Q4. The maximum allowable airspeed under FL100 is 300 Knots.";
Console.WriteLine(V4);
string answerchoicesV4 = "true false";
Console.WriteLine(answerchoicesV4); Console.ReadKey();
string userInput4 = Console.ReadLine();
if (userInput4 == A2)
{
Console.WriteLine("correct");
CorrectAnswers++;
}
else
{
Console.WriteLine("incorrect answer is {0}", A2);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();


const string V5 = "Q5. Vx is the symbol for rotation speed.";
Console.WriteLine(V5);
string answerchoicesV5 = "true false";
Console.WriteLine(answerchoicesV5);
Console.ReadKey();
string userInput5 = Console.ReadLine();
if (userInput5 == A2)
{
Console.WriteLine(" correct ");
CorrectAnswers++;
}
else
{
Console.WriteLine("incorrect answer is {0}", A2);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();

const string V6 = "Q6. Standard atmospheric pressure is ____ ?";
Console.WriteLine(V6);
string answerchoicesV6 = "a.29.92, b.30.02,c.50.05";
Console.WriteLine(answerchoicesV6);
Console.ReadKey();
string userInput6 = Console.ReadLine();
if (userInput6 == A3)
{
Console.WriteLine(" correct ");
CorrectAnswers++;
}
else
{
Console.WriteLine("incorrect answer is {0}", A3);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();

const string V7 = "Q7. A star above an airport on an regional sectional chart indicates?";
Console.WriteLine(V7);
string answerchoicesV7 = " a.Lighted runway, b.Fuel at airport, c.Free parking";
Console.WriteLine(answerchoicesV7); Console.ReadKey();
string userInput7 = Console.ReadLine();
if (userInput7 == A4)
{
Console.WriteLine("correct ");
CorrectAnswers++;
}
else
{
Console.WriteLine("incorrect answer is {0}", A4);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();

//
const string V8 = "Q8.The Symbol Vy stands for_";
Console.WriteLine(V8);
string answerchoicesV8 = "a.Rotation b.Low approach c.Best Rate";
Console.WriteLine(answerchoicesV8);
Console.ReadKey();
string userInput8 = Console.ReadLine();
if (userInput8 == A5)
{ Console.WriteLine("correct"); CorrectAnswers++; }
else
{
Console.WriteLine("incorrect answer is {0}", A5);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();


const string V9 = "Q9.You will not need to contact ATC when transiting through ";
Console.WriteLine(V9);
string answerchoiceV9 = "a.Class bravo airspace b.Class Delta airspace c.Class E airspace";
Console.WriteLine(answerchoiceV9);
Console.ReadKey();
string userInput9 = Console.ReadLine();
if (userInput9 == A5)
{
Console.WriteLine("Correct");
CorrectAnswers++;
}
else { Console.WriteLine("incorrect answer is {0}", A5); }
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();


const string V10 = "Q10. Blue lines on an VFR sectional indicate?";
Console.WriteLine(V10);
string answerchoicesV10 = "a.Approach vectors b.VFR corridors c.Runways";
Console.WriteLine(answerchoicesV10);
Console.ReadKey();
string userInput10 = Console.ReadLine();
if (userInput8 == A4)
{
Console.WriteLine("correct");
CorrectAnswers++;
}
else { Console.WriteLine("incorrect answer is {0}", A4); }
Console.WriteLine();
{
string End = "You have reached the end of the Quiz please review answers and repeat until you get all 10 correct";
Console.WriteLine(End);
}
Console.WriteLine();
Console.WriteLine();
Console.WriteLine();


;
if (CorrectAnswers < 10) { Console.WriteLine("Score CorrectAnswers:{}", CorrectAnswers); CorrectAnswers++; }

else; }
}
  
}
}

Explanation / Answer

ScreenShot

---------------------------------------------------------------------

Program

/*
* This program to generate 10 question quiz
* with multi choice questions
* and true or false questions
*Give second atempt also
* After generate score
*/
using System;
namespace ENGR115projectMcDowell
{
    class WriteLine
    {
        //Main method
        static void Main(string[] args)
        {
            // introduction.
            string PersonalName = "Matthew McDowell";
            string ProjectName = "ENGR 115 Course Project";
            string Dates = "Aug-Oct 2018";
            //print personal data to screen.
            Console.WriteLine("Welcome to the project for " + PersonalName);
            Console.WriteLine(ProjectName);
            Console.WriteLine(Dates);
            //Print directions
            string directions = "This quiz is made up of 10 questions combination of True/False statements, and multiple choice questions. If you are correct you will not need to repeat the question. If you are wrong you will be required to repeat the question later. Enter answer as = a,b,c,true,false. If not the system will state the answer given is wrong.";
            Console.WriteLine(directions);
            //check want to play
            Console.Write("Do you want to continue(Y/N) :");
            Char ch = Console.ReadKey().KeyChar;
            ch = char.ToUpper(ch);
            if (ch == 'Y')
            {
                string Start = "Lets Begin";
                Console.WriteLine(Start);
                //Clear the screen
                Console.Clear();
                //Creating object
                WriteLine wl = new WriteLine();
                Console.WriteLine("Score is {0}", wl.takeQuiz());
                Console.ReadKey();
            }
            else
            {
                Console.WriteLine(" Attempt next time!!!!");
            }
        }


        //Method that returns questions
        string getQuestions(int i)
        {
            string[] questions =
            {
                   "Q1. What does the symbole Vr indicate?",
                   "Q2. Va is the maximum allowable structural speed for full defection of control surfaces on an aircraft",
                   "Q3. Vso is the velocity of stall speed for an aircraft.",
                   "Q4. The maximum allowable airspeed under FL100 is 300 Knots.",
                   "Q5. Vx is the symbol for rotation speed.",
                   "Q6. Standard atmospheric pressure is ____ ?",
                   "Q7. A star above an airport on an regional sectional chart indicates?",
                   "Q8.The Symbol Vy stands for_",
                   "Q9.You will not need to contact ATC when transiting through ",
                   "Q10. Blue lines on an VFR sectional indicate?"
                 };

            return questions[i];
        }

        //Method that returns answers
        string getAnswers(int i)
        {
            string[] answers =
            {
                   "a.Rotation b.Best angle of climb c.Best rate of climb",
                   "True False",
                   "True False",
                   "True False",
                   "True False",
                   "a.29.92 b.30.02 c.50.05",
                   "a.Lighted runway b.Fuel at airport c.Free parking",
                   "a.Rotation b.Low approach c.Best Rate",
                   "a.Class bravo airspace b.Class Delta airspace c.Class E airspace",
                   "a.Approach vectors b.VFR corridors c.Runways"
                 };

            return answers[i];
        }

        //Method that returns correct answers
        string getCorrectAnswers(int i)
        {
            string[] correctanswer =
            {
                "a",
                "true",
                "true",
                "false",
                "false",
                "a",
                "b",
                "c",
                "c",
                "b"
                };

            return correctanswer[i];
        }

        //Validates the input
        Boolean validateInput(string answer, string correctAnswer)
        {
            //For true/false questions
            if (correctAnswer.Equals("true") || correctAnswer.Equals("false"))
            {
                if (answer.Equals("true") || answer.Equals("false"))
                {
                    return true;
                }
                else
                {
                    Console.WriteLine(" Invalid Answer!!! Answer as either True/False... ");
                    return false;
                }
            }
            else
            {
                if (answer.Equals("a") || answer.Equals("b") || answer.Equals("c"))
                {
                    return true;
                }
                else
                {
                    Console.WriteLine(" Invalid Answer!!! Answer as either a/b/c... ");
                    return false;
                }
            }
        }

        //Game
        int takeQuiz()
        {
            //Variables
            int scoreCard = 0; // everyone starts with 0 correct out of ten. once quiz is completed score will be listed as 1-10.

            int[] questionsIncorrect = new int[10];

            Console.WriteLine();
            int j = -1;
            string check;

            Console.WriteLine("Attempt No 1");
            for (int i = 0; i < 10; i++)
            {
                System.Console.WriteLine("{0}", getQuestions(i));
                System.Console.WriteLine("{0}", getAnswers(i));
                System.Console.Write("Enter Answer :: ");
                check = Console.ReadLine();

                //Validating answer
                while (validateInput(check, getCorrectAnswers(i)) == false)
                {
                    //Re-reading
                    check = Console.ReadLine();
                }

                Console.WriteLine();
                if (check.Equals(getCorrectAnswers(i)))
                {
                    scoreCard = scoreCard + 1;
                }
                else
                {
                    j++;

                    questionsIncorrect[j] = i;
                }
                Console.Clear(); // TO CLEAR THE SCREEN
            }
            int k;
            if (j > -1)
            {
                Console.WriteLine("Attempt No 2 for wrong question");
                for (int i = 0; i <= j; i++)
                {
                    k = questionsIncorrect[i];
                    System.Console.WriteLine("{0}", getQuestions(k));
                    System.Console.WriteLine("{0}", getAnswers(k));
                    System.Console.WriteLine("Enter Answer :: ");
                    check = Console.ReadLine();

                    //Validating answer
                    while (validateInput(check, getCorrectAnswers(k)) == false)
                    {
                        //Re-reading
                        check = Console.ReadLine();
                    }

                    Console.WriteLine();
                    if (check.Equals(getCorrectAnswers(k)))
                    {
                        scoreCard = scoreCard + 1;
                        Console.Clear(); // TO CLEAR THE SCREEN
                    }
                    else
                    {
                        System.Console.WriteLine("Correct Answer is {0} ", getCorrectAnswers(k));
                        Console.ReadLine(); // WAIT FOR KEY PRESS
                        Console.Clear(); // TO CLEAR THE SCREEN
                    }

                }

            }

            return scoreCard;
        }
    }
}

---------------------------------------------------------

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