Explore BrainMass

Random Number Generation program in Java

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

I need help with this:

Exercise 6.30:

Computers are playing an increasing role in education. Write a program that will help an elementary school learn multiplication. Use a Random object to produce two positive one-digit integers. The program should then prompt the user with a question, such as

How much is 6 times 7?

The student then inputs the answer. Next, the program checks the students answer. If it is correct, display the message "Very good!" and ask another multiplication question. If the answer is wrong, display the message "No. Please try again." And let the student try the same question repeatedly until the student finally gets it right. A separate method should be used to generate each new question. This method should be called once when the application begins execution and each time the user answers the question correctly.

© BrainMass Inc. brainmass.com October 25, 2018, 1:09 am ad1c9bdddf

Solution Preview


Just as in the previous post, I have attached three files:

a) Multiply.Java
b) ...

Solution Summary

The objective of this Java program is to accept two random numbers from the user and then multiply the two numbers. The application is comprehensive and includes comments as well as documentation.

See Also This Related BrainMass Solution

C# and Java Applications: Random Number Generation Examples

1. Write a C# application that generates a 3-digit random number 100 times. Display the output for each of the generated numbers and the sum of all 100 numbers. Every 10th number you should display a String consisting of any phrase of your choice concatenated with the current random number.
A possible partial output for your program is shown below:
This 10th number is: 834

Demonstrate your code compiles and runs without issue. (You can use screen captures to demonstrate this functionality in a word document).

2. Submit your java file together with a text file containing your test data. Test data in this case is simply a list of inputs and corresponding outputs of your test program.
(Eliminating duplicates) Write a method to eliminate the duplicate values in the array using following method header:
Public static int [ ] eliminateDuplicates (int [ ] numbers)
Write a test program that reads in ten integers, invoke the method, and displays the result.
Here is the sample run of the program:
Enter ten numbers: 1 2 3 2 1 6 3 4 5 2 Enter
The distinct numbers are: 1 2 3 6 5 4

View Full Posting Details