Question
Using Java: Please follow requirements: The program shall generate random numbers with a SecureRandom object The program shall ask the student to enter a difficulty
Using Java:
Please follow requirements:
- The program shall generate random numbers with a SecureRandom object
- The program shall ask the student to enter a difficulty level of 1, 2, 3, or 4
- A difficulty level of 1 shall limit random numbers to the range of 0-9, inclusive
- A difficulty level of 2 shall limit random numbers to the range of 0-99, inclusive
- A difficulty level of 3 shall limit random numbers to the range of 0-999, inclusive
- A difficulty level of 4 shall limit random numbers to the range of 0-9999, inclusive
- The program shall ask the student to solve 10 different multiplication problems
- Multiplication problems shall contain two numbers sampled from a uniform random distribution with bounds determined by the problem difficulty
- 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 "readDifficulty" that reads the difficulty level from the student
- Create a function called "generateQuestionArgument" that uses the difficulty level to generate a random number
- 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 student's score and appropriate score response
- Create a main method that runs your program by calling the "quiz" method
##Code from part 3:##
import java.util.*;
public class Quiz { public static void main(String[] args) { quiz(); }
public static void quiz() { Random rand = new Random();
Scanner sc=new Scanner(System.in); int i=1,c=0,r=0;
while (i
i++; } displayCompletionMessage(c); //calling displayCompletionMessage() by taking no.of correct answers as parameter System.out.println("Do you want to solve another new problem(Y/N)?"); char ch=sc.next().charAt(0); if(ch=='Y') quiz(); //reseting the game else System.exit(0); //terminate the program }
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; } } public static void displayCompletionMessage(int c) { float p=(float)c/10*100; //calculation of score percentage System.out.println("Your Score is"+p+"%"); if(p>=75) System.out.println("Congratulations, you are ready to go to the next level!"); else System.out.println("Please ask your teacher for extra help."); }
}
##
Part 4 Modify the program from Part 3 to allow the user to enter a difficulty level. At a difficulty level of 1, the program should use only single-digit numbers in the problems; at a difficulty level of 2, numbers as large as two digits, and so on. Allow for four levels of difficulty. Part 4 Modify the program from Part 3 to allow the user to enter a difficulty level. At a difficulty level of 1, the program should use only single-digit numbers in the problems; at a difficulty level of 2, numbers as large as two digits, and so on. Allow for four levels of difficultyStep 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