我必须做10个问题测验,5个是非题和5个问题多项选择。这需要使用方法来完成。我遇到的问题是程序没有按顺序执行,而不是首先执行“班级用户”,其次是“班级测验”,然后是第三级。它仅在执行“类测验”并关闭。另外,程序没有显示错误。
class User
{
internal string name;
public static void Name(string[] args)
{
Console.WriteLine("Aeronautical Knowledge Quiz.");
Console.WriteLine("This Quiz consists of 10 questions.");
Console.WriteLine("5 True or False and 5 Multiple choice.");
Console.WriteLine("Please enter your name (last, first) and press ENTER.");
string name = Console.ReadLine();
Console.Clear();
Console.WriteLine("Welcom to the Aeronautical Knowledge Quiz " + name + "!");
Console.WriteLine("NOTE: This quiz is case sensitive.");
Console.WriteLine();
Console.WriteLine("Press ENTER to begin the quiz.");
Console.ReadLine();
Console.Clear();
}
}
class Quiz
{
internal string correctAnswer;
internal string qcounter;
public static void Main(string[] args)
{
string[] questions = { "The fuselage is the center structure of an aircraft and provides the connection for the wings and tail. (True or False)?",
"Rolling is the action on the lateral axis of an aircraft. (True or False)?",
"Drag is the name of the force that resists movement of an aircraft through the air. (True or False)?",
"Flaps are attached to the trailing edge of a wing structure and only increases drag. (True or False)?",
"Powerplant or engine, produces thrust to propel an aircraft. (True or False)?",
"Which of the following are part of an aircraft primary flight controls? a.Aileron. b.Rudder. c.Elevators. d. All the above.",
"The Fuel-air control unit of a reciprocating engine? a.Sends fuel to the piston chamber. b.Sends air to the piston chamber. c.Controls the mixture of air and fuel. d.Meters the quantity of fuel.",
"Which of the following is the main source of electrical power when starting an aircraft? a.Primary Bus. b.Avionics Bus. c.Battery. d.GPU (ground power unit)",
"The reservoir of a hydraulic system is used for? a.Store and collect fluid from a hydraulic system. b.Lubricate components when needed. c.Keep the fluid clean. d.All the above.",
"Flying into fog can create. a.Narrows the runway. b.An aircraft to stall. c.An illusion of pitching up. d.A stressful environment for the Pilot and Co-pilot." };
string[] answers = { "True", "True", "True", "False", "True", "d", "c", "c", "a", "c" };
string studentAnswer;
float correctAnswer = 0;
float qcounter = 0;
var questionNum = 0;
var answerNum = 0;
while (questionNum < questions.Length)
{
Console.WriteLine(questions[questionNum], 10, 30);
studentAnswer = Console.ReadLine();
if (studentAnswer == answers[answerNum])
{
Console.WriteLine("Correct!");
questionNum++;
answerNum++;
correctAnswer++;
qcounter++;
}
else
{
Console.WriteLine("Incorrect.");
questionNum++;
answerNum++;
qcounter++;
}
Console.WriteLine();
Console.WriteLine("Press ENTER for Next question.");
Console.ReadLine();
Console.Clear();
}
}
}
class Score
{
static void Value(string[] args)
{
User n = new User();
Quiz m = new Quiz();
Console.WriteLine(n.name + ", Your final score is: " + m.correctAnswer + "/" + m.qcounter + ".");
Console.WriteLine();
Console.WriteLine("Press ENTER to EXIT");
Console.ReadKey(true);
}
}