Nested Loops Lab: Quiz: Fall 2024
Learning Objective(s)
- Improve skill with arrays
- Work with 2d arrays
Overview of the Program
Adapt lab 5 (the quiz program) to use arrays and to continue to ask questions (in a random order) until all are answered correctly
Specifics
- The program is to be called Quiz
- You may use the posted solution to lab 5 if you wish (be sure to indicate that in "Outside Resources"
- Load the data into arrays (one array for the question, a 2D array for the possible answers, and an array for the correct answer) one time
- Use constants for the maximum number of questions and for the exact number of possible answers
- Use a constant for the name of the file containing the first quiz.
- Catch all IO Exceptions
- Allow the user to do multiple quizzes.
- The user is to input the name of the file that contains the quiz.
- Output the statistics at the end of each quiz
- After each question, the program should inform the user if he/she answered it correctly.
- You must have one event controlled loop and one count controlled loop.
- Be sure to close the file.
Sample dialogue
Below is a sample dialogue. Your output can vary somewhat as long as the required data is nicely displayed.
Question: What is 2 + 2?
A) 1
B) 2
C) 3
D) 4
Answer? D
You were correct.
Question: What color is the sky?
A) blue
B) yellow
C) black
D) grey
Answer? A
You were correct.
There were 2 in the quiz.
You took 2 answers to get them all right.
That means you scored 100.00 percent.
Again? yes
Name of next quiz file? simplequiz.txt
Question: What color is the sky?
A) blue
B) yellow
C) black
D) grey
Answer? A
You were correct.
Question: What is 2 + 2?
A) 1
B) 2
C) 3
D) 4
Answer? B
You were wrong.
Question: What is 2 + 2?
A) 1
B) 2
C) 3
D) 4
Answer? D
You were correct.
There were 2 in the quiz.
You took 3 answers to get them all right.
That means you scored 66.67 percent.
Again? no
You can also run a solution for this program if you want. See classroom instructions for more details.
Lab Hints
Submission
- Create a software development report
- For the system design, you may use my flowchart if it is the design of your program. It is incomplete. You will need to finish it
- For testing report,
- adapt the testing form so that the input column could also include instructions to the tester
- test your loops well:
- Test for different number of questions
- Test for a different number of answers
- Test for different %'s of number correct
- Include the details of one data file. You can just describe the rest
- For the improvement section, specify how many points were lost from the last lab that you should not lose points for on this lab because you corrected the problem
- create a pdf document from your software development report
- create an empty zip folder
- place only Quiz.java and your pdf document into it
- submit the zip folder on canvas
Optional improvements
Optional improvements should ONLY be worked on once the program is completing working. In addition, the work is to be done on your own with little if any help for lab assistants or the instructor.
- Get the first file name (or all file names) from command line arguments. This you must research on your own. There will be no help from any lab assistant or instructor or any other live human being to do this. Be sure to document the outside resource if you do this option
- Allow for the user to use upper or lower case when given their answer
- Save the program as QuizExtra.java and include it in the zip folder