Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WhatsApp 11 LTE 26%D 4:03 PM chegg.com - Private java helper please In this assignment, you will modify your Quix class from the previous assignment.

image text in transcribed
image text in transcribed
image text in transcribed
WhatsApp 11 LTE 26%D 4:03 PM chegg.com - Private java helper please In this assignment, you will modify your Quix class from the previous assignment. You will create a method that asks a quer question and a method that check the answer and you will those methods to ask multiple questions. Your program will then report how many questions the pot correct. This program will be the basis for future Programming Assignments in this These instruction assume that you are using the Eclipse IDE your c u rryou may we a different Java c om as long as you can provide lava code and screenshots for your in the Fostepen your previous Programming Assignment in Eclipse, with the file de pe Add a static method that ask a question until the user provides valid input Call the method ask It should take a String parameter, and it should return a String static String ask (String question) . Remember where method definitions all other method definitions like ma inside the class in this case, but outside t can go before or after the main definition Ask the user the question repeatedly until the user provides a valid answer:"A", "B"."C" "D", "E Ask the question using OptionPane show Input Dialog Allow the user to provide a lower-case answer, and convert it to uppercase If the user provides an invalid answer useOptionPane show MessageDialog to tell them. "Invalid answer. Please enter ABCD or E." Then ask the question again Repeat until the answer is valid Once the user provides a valid answer, return that answer converted to uppercase) Notice that the method does not check whether the answer is correct. It just asks the same question until the answer is valid Try out your new method Delete the existing loop from your main method, but leave the initialization of the questo String Call the method with your question String as the argument (actual parameter) Note that you do not have to use the String returned by Run It should be askine the cuestion until you movide a valid answer This question hasn't been answered yet Ask an expert WhatsApp Il LTE 25%D 4:04 PM chegg.com - Private . Note that you do not have to use the String returned by ask Run your program. It should keep asking the question until you provide a valid answert does not yet check the answer . Try invalid and valid answers Now add a method that ask questions using ask and checks answers Call the method "checkIt should take two String parameters, static void check(String question, String correct Answer) The method definition can go before, after, or between the definitions for ask and "main", but it must be inside the Qui" class and outside the other method definitions In the chest method calls to get a valid awer String answer ask (question): If the answer is correct, use "Option Pane show MessageDialog to report, Correct!" . If the answer is incorrect, use Option Pane show MessageDialog" to report, "Incorrect The correct answer is."This output should include the actual correct answer Test the "check" method Replace the "ask"call in the main method with a "check" call. You will need to provide both the question String and the answer Sering as arguments Run your program. It should keep asking the question until you provide a valid answer Then it should tell you if your answer is correct Try invalid, incorrect, and correct answers Add more questions . In the main method, call check with at least two more unique quix questions, each with a different correct answer for a total of at least three questions You may either declare and initialize variable after each check call w local variables or reassign the existing question Run your program. Make sure the responses work as expected for all the questions Finally, add a score for the quiz Add two static member variables, one for the number of questions and one for the number of the freedom This question hasn't been answered yet Ask an expert WhatsApp LTE 4:04 PM 25%O chegg.com - Private WWW , a different correct answer for a total of at least three questions . You may either declare and initialire new local variables or reassign the existing question variable after each check call Run your program. Make sure the responses work as expected for all the questions Finally, add a score for the quiz Add two static member variables, one for the number of questions and one for the number of corect answers. Initialize them to zero for good documentation static int nQuestions ; static int nCorrect : Remember where member variables go inside a class definition but outside all method definitions. You may declare the variables before, after, or between the existing methods In the "check" method, increment Questions each time it is called Also in the "check" method, increment Correct" for cach correct answer Display the score at the end of the man method using "OptionPane show MessageDialog". Use the text, correct out of questions with the appropriate numbers Run your program. Make sure it displays the right numbers of questions and correct answers Show transcribed image text Expert Answer o This question hasn't been answered yet Ask an expert WhatsApp 11 LTE 26%D 4:03 PM chegg.com - Private java helper please In this assignment, you will modify your Quix class from the previous assignment. You will create a method that asks a quer question and a method that check the answer and you will those methods to ask multiple questions. Your program will then report how many questions the pot correct. This program will be the basis for future Programming Assignments in this These instruction assume that you are using the Eclipse IDE your c u rryou may we a different Java c om as long as you can provide lava code and screenshots for your in the Fostepen your previous Programming Assignment in Eclipse, with the file de pe Add a static method that ask a question until the user provides valid input Call the method ask It should take a String parameter, and it should return a String static String ask (String question) . Remember where method definitions all other method definitions like ma inside the class in this case, but outside t can go before or after the main definition Ask the user the question repeatedly until the user provides a valid answer:"A", "B"."C" "D", "E Ask the question using OptionPane show Input Dialog Allow the user to provide a lower-case answer, and convert it to uppercase If the user provides an invalid answer useOptionPane show MessageDialog to tell them. "Invalid answer. Please enter ABCD or E." Then ask the question again Repeat until the answer is valid Once the user provides a valid answer, return that answer converted to uppercase) Notice that the method does not check whether the answer is correct. It just asks the same question until the answer is valid Try out your new method Delete the existing loop from your main method, but leave the initialization of the questo String Call the method with your question String as the argument (actual parameter) Note that you do not have to use the String returned by Run It should be askine the cuestion until you movide a valid answer This question hasn't been answered yet Ask an expert WhatsApp Il LTE 25%D 4:04 PM chegg.com - Private . Note that you do not have to use the String returned by ask Run your program. It should keep asking the question until you provide a valid answert does not yet check the answer . Try invalid and valid answers Now add a method that ask questions using ask and checks answers Call the method "checkIt should take two String parameters, static void check(String question, String correct Answer) The method definition can go before, after, or between the definitions for ask and "main", but it must be inside the Qui" class and outside the other method definitions In the chest method calls to get a valid awer String answer ask (question): If the answer is correct, use "Option Pane show MessageDialog to report, Correct!" . If the answer is incorrect, use Option Pane show MessageDialog" to report, "Incorrect The correct answer is."This output should include the actual correct answer Test the "check" method Replace the "ask"call in the main method with a "check" call. You will need to provide both the question String and the answer Sering as arguments Run your program. It should keep asking the question until you provide a valid answer Then it should tell you if your answer is correct Try invalid, incorrect, and correct answers Add more questions . In the main method, call check with at least two more unique quix questions, each with a different correct answer for a total of at least three questions You may either declare and initialize variable after each check call w local variables or reassign the existing question Run your program. Make sure the responses work as expected for all the questions Finally, add a score for the quiz Add two static member variables, one for the number of questions and one for the number of the freedom This question hasn't been answered yet Ask an expert WhatsApp LTE 4:04 PM 25%O chegg.com - Private WWW , a different correct answer for a total of at least three questions . You may either declare and initialire new local variables or reassign the existing question variable after each check call Run your program. Make sure the responses work as expected for all the questions Finally, add a score for the quiz Add two static member variables, one for the number of questions and one for the number of corect answers. Initialize them to zero for good documentation static int nQuestions ; static int nCorrect : Remember where member variables go inside a class definition but outside all method definitions. You may declare the variables before, after, or between the existing methods In the "check" method, increment Questions each time it is called Also in the "check" method, increment Correct" for cach correct answer Display the score at the end of the man method using "OptionPane show MessageDialog". Use the text, correct out of questions with the appropriate numbers Run your program. Make sure it displays the right numbers of questions and correct answers Show transcribed image text Expert Answer o This question hasn't been answered yet Ask an expert

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions