Question: I need some help with this weeks code. This is what was asked. This week, you will optimize the existing project code by implementing methods.

I need some help with this weeks code. This is what was asked.

This week, you will optimize the existing project code by implementing methods. Additionally, you will test the code for non-permissible input value(s) of the variable(s) and document your test results. Improve your code by adding a statement that displays an error message.

I have the following, where do I go from here?

This is in C#, it would not let me select that as a subject.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace AviationQuiz

{

//Create the class.

class Quiz

{

//Define the main method.

static void Main(string[] args)

{

//Introduction Text

Console.Title = "Aviation Quiz";

Console.WriteLine("Created by Kory Stanfill");

Console.WriteLine("Aviation Questions");

Console.WriteLine("ENGR 115: Checkpoint 2"); ;

//Create the Questions

string[] questions ={"You pitch up in an airplane that has a balance tab on its elevator. Which way does the tab move??"

,"You're flying a Piper Cherokee. If your alternator fails in cruise flight, your engine will continue running."

,"You're preflighting a Cessna 172 and you see this hole on the side of the cowl. What is it?"

,"What changes the prop's pitch on this constant speed propeller hub?"

,"Air temperature heats up as it passes through the Venturi of a carburetor."

,"An aircraft with an aft CG requires what than the same aircraft with a forward CG?"

,"Which of these factors has the greatest effect on density altitude?"

,"A single engine aircraft at max gross weight will have a climb rate of _______ at its service ceiling."

,"You're flying a cross country from an area of high pressure to an area of low pressure. If you don't reset your altimeter, your plane will be lower than the indicated altitude on your altimeter."

,"An aircraft in a constant altitude, 60-degree bank turn has a load factor of what?"};

Boolean[] status = { false, false, false, false, false, false, false, false, false, false };

//Create the Answers

string[] answers = { "A. Up B. Down C. Left D. Right",

"A. True B. False"

,"A. Water Drain B. Turbo boost relief valve C. Outside air temp gauge D. Static Port"

,"A. Air Pressure B. Electric Gearing C. Oil Pressure D. Water Pressure"

,"A. True B. False"

,"A. More tail down force B. Less tail down force C. More nose down force D. Less nose down force"

,"A. Barometric Pressure B. Temperature C. Humidity D. Air pollution"

,"A. 0 FPM B. 50 FPM C. 100 FPM D. 150 FPM"

,"A. True B. False"

,"A. 1 G B. 1.4 G C. 2 G D. 2.5" +

""};

//Create the key for the Answers

string[] key = { "B", "A", "D", "C", "B", "B", "B", "C", "A", "C" };

int noCorrectAnswer = 0;

for (int i = 0; i < 10; i++)

{

Console.WriteLine(questions[i]);

Console.WriteLine(answers[i]);

Console.Write("Enter the answer: ");

string choice = Console.ReadLine();

if (choice == key[i])

{

noCorrectAnswer += 1;

status[i] = true;

}

}

//Create the loop for the questions that are incorrect

Console.WriteLine("Re-Start Quiz================================");

Console.WriteLine("Repeat the quiz for wrong answered questions!");

for (int i = 0; i < 10; i++)

{

if (status[i] == true)

{

Console.WriteLine(questions[i]);

Console.WriteLine(answers[i]);

Console.Write("Enter the answer: ");

string choice = Console.ReadLine();

if (choice == key[i])

{

noCorrectAnswer += 1;

status[i] = true;

}

}

}

//Display the number of questions answered correctly

Console.WriteLine("Number of correct Answers: " + noCorrectAnswer);

Console.ReadKey();

}

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!