Answered step by step
Verified Expert Solution
Link Copied!
Question
1 Approved Answer

##Part 1 code:## import java.security.SecureRandom; import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // declare SecureRandom

image text in transcribed

##Part 1 code:##

import java.security.SecureRandom; import java.util.Scanner;

public class Test { public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

// declare SecureRandom object SecureRandom rand = new SecureRandom();

// generate two signle digit random numbers int first = rand.nextInt(10); int second = rand.nextInt(10);

// show the question int ans = first * second; System.out.println("how much is " + first + " times " + second + "? ");

// start a infinite loop while (true) {

// ask user for input System.out.print("Ans. "); int user = sc.nextInt();

// check answer if (user == ans) { // show congratulate user for right answer System.out.println(); System.out.println("Very good!"); break; }

// ask another another answer when first answer is wrong System.out.println(); System.out.println("No. Please try again."); }

sc.close();

}

}

##Part 1 output##

image text in transcribed

Part 2 Modify the program from Part 1 so that various comments are displayed for each answer as follows: Possible responses to a correct answer: Very good! Excellent! Nice work! Keep up the good work! Possible responses to an incorrect answer: No. Please try again. Wrong. Try once more. Don't give up! No. Keep trying. Use random-number generation to choose a number from 1 to 4 that will be used to select one of the four appropriate responses to each correct or incorrect answer. Use a switch statement to issue the responses. Requirements The program shall generate random numbers with a Secure Random object The program shall ask the student to solve a multiplication problem A multiplication problem 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 terminate when a correct response is provided by the student The program shall continue to ask the student to solve the original multiplication problem until the student provides the correct answer 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 "isAsnwerCorrect" 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 "displaylnorrectResponse" that prints out the response when a student enters an incorrect answer Part 1: Create a main method that runs your program by calling the "quiz" method

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

Oracle 12c SQL

Authors: Joan Casteel

3rd edition

1305251032, 978-1305251038

More Books

Students explore these related Databases questions