OK, staff, we received many applications for our astronaut training program, and we need to do an initial evaluation of the candidates. Management needs you to create a quick quiz to help select the best candidates.
The requirements below are what your END assignment will look like. This assignment is broken down so you can complete small pieces as you go. You need to move sequentially starting at Part 1. Please read the WHOLE assignment page before starting.
When starting any project, it's best to approach it as a series of smaller, testable parts. The goal is to get simple parts working first and then expand the code in a systematic way. The following is NOT the only way to complete this assignment, but it provides a framework for thinking through the project.
TODO 1.1ain the starter code. On the line below this TODO comment, define a variable called
candidateNamewith an initial value of the empty string.
TODO 1.1b. Inside of the function
askForName(), write code asking the user to enter their name into the program and store the value as
TODO 1.1c. Underneath it, write a message to the console greeting the user using the name they just provided.
Ask the user to answer a single quiz question. Look for
Below the TODO comment, define variables called
questionshould be initialized to the following string:
"Who was the first American woman in space? ".
Note the trailing space at the end of this string is required.
correctAnswershould be initialized to
candidateAnswerwill initially be set to the empty string.
TODO 1.2b. Using your question variable, display the question and prompt the candidate for
their answer. Store their response in one of the variables you defined just above.
TODO 1.2c, check the candidate's answer to see if it is correct.
Provide basic feedback to the candidate, letting them know if their answer is correct
Make sure your small app works properly before moving on to part 2.
Now that your small app is working, expand it to deal with multiple questions.
This time, you only have one
TODO item in the starter code. You will need
to determine which lines need to be modified.
correctAnswersvariables as arrays. Use the table below to fill these arrays.
TODO 1.2bwith a loop that programmatically asks each question in the array and stores the user's responses.
TODO 1.2cwith a template literal that displays each of the candidate's responses in addition to the corresponding correct answers.
|Who was the first American woman in space?||"Sally Ride"|
|True or false: 5 kilometer == 5000 meters?||"true"|
|(5 + 3)/2 * 10 = ?||"40"|
|Given the array
|What is the minimum crew size for the ISS?||"3"|
Keep the questions and correct answers stored in this exact order.
Finally, calculate the candidate's score and print the results. There are no
TODOs in this section,
just be sure to only modify code that you have written, or add code. Don't remove anything in the file
that you haven't written. Doing so may cause your program to behave unexpectedly - and we might not be able to grade it!
Your task here is to:
Checking for the correct answer should be case insensitive (e.g. "Orbit" is the same as "orbit").
TODO 1.2c you should see a variable declaration for
grade. Use this to calculate the candidate's
To calculate the candidate's percentage, use the equation:
(Number of Correct Answers) / (Number of Quiz Questions) * 100
The results output should include the candidate's name, the candidate's responses, the correct answers, the final percentage, and if the candidate passed the quiz.
Candidate Name: Can Twin 1) Who was the first American woman in space? Your Answer: sally ride Correct Answer: Sally Ride 2) True or false: 5000 meters = 5 kilometers. Your Answer: false Correct Answer: true 3) (5 + 3)/2 * 10 = ? Your Answer: 45 Correct Answer: 40 4) Given the array [8, "Orbit", "Trajectory", 45], what entry is at index 2? Your Answer: trajectory Correct Answer: Trajectory 5) What is the minimum crew size for the ISS? Your Answer: 10 Correct Answer: 3 >>> Overall Grade: 40% (2 of 5 responses correct) <<< >>> Status: FAILED <<<
The output will vary slightly based on the candidate's answers to each question.