Question

Write a program that will help a student learn multiplication. Use SecureRandom object to produce two...

Write a program that will help a student learn multiplication. Use SecureRandom object to produce two positive integers between 1 and 20. The program should then prompt the user with a question (use a sentinel-controlled loop), such as: How much is 10 times 11? The student then inputs the answer. If the answer is correct display the message “very good” and ask another question. If the answer is wrong to display the message “no, please try again” and let the student try the same question until the student finally gets it right. 5 You must create two java files: Multiplication.java and MultiplicationTest.java. In Multiplication add two methods: CreateQuestion and CheckResponse. In MultiplicationTest.java, test your methods. UPLOAD Multiplication.java and MultiplicationTest.java

sample output example:

How much is 15 times 13?

enter your answer (-1 to exit): 425

no, please try again.

enter your answer (-1 to exit): 195 very good!

How much is 7 times 5?

enter your answer (-1 to exit): 35

very good!

How much is 6 times 16?

enter your answer (-1 to exit): -1

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. 

If you are satisfied with the solution, please rate the answer. Let me know for any help with any other questions.

Thank You !
===========================================================================

import java.security.SecureRandom;

public class Multiplication {

    private static SecureRandom random = new SecureRandom ();
    private int numberOne;
    private int numberTwo;


    public void generateQuestion() {
        numberOne = random.nextInt(20) + 1;
        numberTwo = random.nextInt(20) + 1;
    }

    public void displayQuestion() {

        System.out.println("How much is " + getNumberOne() + " times " + getNumberTwo() + "?");

    }

    public boolean isCorrect(int userInput) {
        return userInput == (numberOne * numberTwo);
    }

    public int getNumberOne() {
        return numberOne;
    }

    public int getNumberTwo() {
        return numberTwo;
    }

    public int getAnswer() {
        return getNumberOne() * getNumberTwo();
    }
}

=============================================================

import java.util.Scanner;

public class MultiplicationTest {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int answer = 0;
        Multiplication multiplication = new Multiplication();
        do {
            multiplication.generateQuestion();
            multiplication.displayQuestion();
            while (true) {
                System.out.print("Enter your answer (-1 to exit): ");
                answer = scanner.nextInt();
                if (answer == -1) break;
                if (multiplication.isCorrect(answer)) {
                    System.out.println("Very Good!");
                    break;
                } else {
                    System.out.println("No, please try again.");
                }
            }


        } while (answer != -1);
    }
}

=============================================================

Add a comment
Know the answer?
Add Answer to:
Write a program that will help a student learn multiplication. Use SecureRandom object to produce two...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java Programming Write a program that will help a student learn multiplication. Use SecureRandom object to...

    Java Programming Write a program that will help a student learn multiplication. Use SecureRandom object to produce two positive integers between 1 and 20. The program should then prompt the user with a question (use a sentinel-controlled loop), such as: How much is 10 times 11? The student then inputs the answer. If the answer is correct display the message “very good” and ask another question. If the answer is wrong to display the message “no, please try again” and...

  • Write a JAVASCRIPT program that will help an elementary school student learn multiplication. Use the Random...

    Write a JAVASCRIPT program that will help an elementary school student learn multiplication. Use the Random method to produce two positive one-digit integers. The program should then prompt the user with a question using random numbers, such as How much is 6 times 7? The student then inputs the answer. Next, the program checks the student’s answer. If it is correct, display the message "Very good!" and ask whether the student wants to continue if so then ask another multiplication...

  • Programming in C: Write a program that will help an elementary school student learn multiplication. Use...

    Programming in C: Write a program that will help an elementary school student learn multiplication. Use the random number generator to produce two positive integers between 1 and 12 inclusive. It should then type a question such as:             How much is 6 times 7? The student then types the answer. Your program checks the students’ answer. If it is correct, print a message such as Very good!   If the answer is wrong, print a message such as No. Please...

  • So I can not get this to work properly and he does not want us using...

    So I can not get this to work properly and he does not want us using an array list. Below is the directions along with the code I have(Im not sure the code is in the right format)   ITSE 2321 – OBJECT-ORIENTED PROGRAMMING JAVA Program 7 – Methods: A Deeper Look Write a program that will help an elementary school student learn multiplication. Use a SecureRandom object to produce two positive one-digit integers. The program should then prompt the student...

  • Please put the outputs with it also I want to make sure it runs thanks Project-Computer-Assisted...

    Please put the outputs with it also I want to make sure it runs thanks Project-Computer-Assisted Instruction (50 points) use of computers in education is referred to as computer-assisted instruction (CAl) should then Writ e a program that will help an elementary school student learn multiplication. Use the rand function to produce two positive one-digit integers. The program prompt the user with a question, such as How much is 6 times 7? The student then inputs the answer. Next, the...

  • Android / Java / Please Upload your homework. Copy the screenshot and then paste it to...

    Android / Java / Please Upload your homework. Copy the screenshot and then paste it to this word document. Then zip your word file and java files. Note: if your android project is too big, you can just zip all of the needed xml files and java files. Computer-Assisted Instruction App) Create an app that will help an elementary school student learn multiplication. Select two positive one-digit integers. The app should then prompt the user with a question, such as...

  • Python Object oriented programming Exercise 3 Dictionary Computers are playing an increasing role in education. Write...

    Python Object oriented programming Exercise 3 Dictionary Computers are playing an increasing role in education. Write a program that will help an elementary school student to learn English. To simplify the model, the program will first teach numbers from 1 to 10, colors and fruits. It will use a dictionary to store the pairs Spanish-English words. dataTable-uno':one,'dos':'two....' rojo':'red','blue':'Azul... manzana': apple, nara nja:orange. When running your program, it should get a random Spanish word from the dictionary dataTable and then show...

  • In C++ The Multiplication Program Step 1: Write a program that stores a multiplication table in...

    In C++ The Multiplication Program Step 1: Write a program that stores a multiplication table in a 9-by-9 two-dimensional array. Generate the multiplication table with two loops. (So you will have a nested loop that will iterate 9 times and fill the 9x9 array with the values.) Step 2: Display the table for the user to see it. a 9x9 table Step 3: Create a function that returns the product of two numbers between 1 and 9by looking up the...

  • This week we looked at an example math program that would display the answer to a...

    This week we looked at an example math program that would display the answer to a random math problem. Enhance this assignment to prompt the user to enter the solution to the displayed problem. After the user has entered their answer, the program should display a message indicating if the answer is correct or incorrect. If the answer is incorrect, it should display the correct answer. The division section should use Real data types instead of Integer data types. Keep...

  • USING A PYTHON Write a program that gives simple math quizzes. The program should display two...

    USING A PYTHON Write a program that gives simple math quizzes. The program should display two random numbers that are to be added, such as: 247 + 129 The program should allow the student to enter the answer. If the answer is correct, a message of congratulations should be displayed. If the answer is incorrect, a message showing the correct answer should be displayed.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT