Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java programming When finished this lab will create a free-response quiz with up to 25 questions. The displayed questions can be displayed based upon their

java programming

When finished this lab will create a free-response quiz with up to 25 questions. The displayed questions can be displayed based upon their rigor level. The answers will be checked, and the results displayed. There are 4 parts to this lab. It is recommended that you complete it in the order listed below, and compile each and correct any errors before moving to the next part.

Part 1: Write an interface called Rigor with 2 methods: getRigor and setRigor. getRigor has no parameters and returns an integer. setRigor accepts an integer parameter and has no return statement. Compile before moving on to Part 2.

Part 2: Write the class QandA that implements the Rigor interface. There are three attributes: String question, String answer, and an integer representing the rigor level. Have a constructor method which takes in a question, its answer, and the rigor level. Also include accessor methods for the question and for the answer. Have an additional method called checkAnswer that checks if the passed in answer matches the correct answer and returns a boolean. The toString method should return the question, the rigor level, and its answer.

Part 3: Write the Quiz class that has one class variable (a constant) for the maximum number of questions per quiz, set to 25. There are four state variables: an array (not an ArrayList) called questions that holds QandA objects, and three additional integer state variables that represent the number of correct answers, incorrect answers, and the total number of quiz questions. Have a default constructor. Have a method called addQuestion that accepts a QandA object and adds it if there is space remaining. Have a method called getQuizQuestions that accepts an integer and returns the question at the passed in value. Write an overloaded method to getQuizQuestions that also accepts two integer parameters that specify the minimum and maximum rigor levels and returns that question within the rigor range or returns Question does not have the specified rigor. Also have three additional accessor methods for the number of current questions, the number of correct answers, and the number of incorrect answers. Have a method called checkAnswer that accepts an integer representing the question number and a String answer. It should check the passed in answer (case does not matter) and increment either the correct or incorrect variable. The toString method should return the number of total questions, along with the number correct and incorrect.

Part 4: Write the QuizRunner class with the main method. Create a quiz object and add the following (see the next page) to the quiz. Add additional questions of your own. Prompt the user to see if they want all the questions or only those within a specific rigor range. Display the questions. Prompt the user for each answer and display the results.

(next page for part 4)

Question 1: What is the wind speed flight velocity of a swallow? Answer: African or European? Rigor: 2 Question 2: What color was George Washington's white horse? Answer: white Rigor: 1 Question 3: How much wood could a woodchuck chuck? Answer: a lot Rigor: 2 Question 4: What is my favorite programming language? Answer: Java Rigor: 1 Question 5: How many moons does the planet Venus have? Answer: zero Rigor: 4 Question 6: Outside of USA, what is the largest software producing county? Answer: Ireland Rigor: 4 Question 7: About how many bytes is a megabyte? Answer: one million Rigor: 3 Question 8: What is an eleven-sided polygon called? Answer: undecagon Rigor: 3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

Students also viewed these Databases questions

Question

Explain how corporate profits are taxed twice.

Answered: 1 week ago

Question

Cite examples of how experiences alter brain anatomy and function.

Answered: 1 week ago

Question

=+organizations and employees differently.

Answered: 1 week ago