Question
Using Java: Please follows requirements: The program shall generate random numbers with a SecureRandom object The program shall ask the student to solve 10 different
Using Java:
Please follows requirements:
- The program shall generate random numbers with a SecureRandom object
- The program shall ask the student to solve 10 different multiplication problems
- Multiplication problems shall contain two numbers sampled from a uniform random distribution in the range of 0 to 9 (inclusive)
- The program shall display a random positive message if the student provides a correct response
- The program shall display a random negative message if the student provides an incorrect response
- The program shall display the student's score after the student has attempted to solve 10 problems
- The student's score shall be the percentage of problems correctly solved
- The program shall display the message "Please ask your teacher for extra help." if the student's score is less than 75%
- The program shall display the message "Congratulations, you are ready to go to the next level!" if the student's score is greater than or equal to 75%
- The program shall ask the student if they want to solve a new problem set after the score message has been displayed
- The program shall restart when the student agrees to solve a new problem set
- The program shall terminate when the student declines to solve another problem set
- Create a method called "quiz" that contains the program logic
- Create a function called "askQuestion" that prints the problem to the screen
- Create a function called "readResponse" that reads the answer from the student
- Create a function called "isAnswerCorrect" that checks to see if the student's answer matches the correct answer to the problem
- Create a function called "displayCorrectResponse" that prints out the response when a student enters a correct answer
- Create a function called "displayIncorrectResponse" that prints out the response when a student enters an incorrect answer
- Create a function called "displayCompletionMessage" that prints out the studen't score and appropriate score response
- Create a main method that runs your program by calling the "quiz" method
##Code from part 2:##
import java.util.*;
public class Quiz { public static void main(String[] args) { quiz(); }
public static void quiz() { Random rand = new Random();
int num1 = rand.nextInt(10); int num2 = rand.nextInt(10);
while (true) { int val1 = askQuestion(num1, num2); int val2 = readResponse(); if (val1 == val2) { displayCorrectResponse(); break; } displayIncorrectResponse(); }
}
public static int readResponse() { Scanner scn = new Scanner(System.in); int val = scn.nextInt(); return val; }
public static int askQuestion(int num1, int num2) {
System.out.println("How much is " + num1 + " times " + num2); return num1 * num2; }
public static boolean isAnswerCorrect(int val1, int val2) {
if (val1 == val2) { return true; } return false; }
public static void displayCorrectResponse() { Random rand = new Random();//make here random function and then int ForRep = rand.nextInt(4)+1;//it will generate one random number with 1 to 4 switch (ForRep) { case 1: System.out.println("Very Good!");//output display break; case 2: System.out.println("Excelent!");//output display break; case 3: System.out.println("Nice Work!");//output display break; case 4: System.out.println("Keep Up The Good Work");//output display break; } }
public static void displayIncorrectResponse() { Random rand = new Random();//make here random function and then int ForRep = rand.nextInt(4)+1;//it will generate one random number with 1 to 4 switch (ForRep) {//display here case 1: System.out.println("No. Please try again.");//output display break; case 2: System.out.println("Wrong.Try Once More.");//output display break; case 3: System.out.println("Don't Give Up!");//output display break; case 4: System.out.println("No Keep Trying.");//output display break; } }
}
##
Part 3 Modify the program from Part 2 to use your question generation method to ask the student 10 different questions. Give students only one chance at answering each question. Count the number of correct and incorrect responses typed by the student. After the program has asked 10 questions (and the student types 10 answers), your program should calculate the percentage that are correct. If the percentage is lower than 75%, display "Please ask your teacher for extra help.", then reset the program so another student can try it. If the percentage is 75% or higher, display "Congratulations, you are ready to go to the next level!", then reset the program so another student can try itStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started