Question

Need a program in java that creates a random addition math quiz The program should ask...

Need a program in java that creates a random addition math quiz

The program should ask the user to enter the following

The smallest and largest positive numbers to be used when generating the questions -

The total number of questions to be generated per quiz -

The total number of the quiz's to create

from then the program should generate a random math (Just addition) quiz from what the user entered

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the program below:

import java.util.Scanner;
import java.util.Random;
class quiz {
  
public static void main(String args[]) {
   int sum , output1;
System.out.println
("Enter the smallest positive number : ");
Scanner input1 = new Scanner(System.in);
int small_number = input1.nextInt();
System.out.println("Enter the largest positive number : ");
int large_number = input1.nextInt();
System.out.println("Enter the total number of questions to be generated per quiz : ");
int ques_number = input1.nextInt();
System.out.println("Enter the total number of the quiz's to create : ");
int quiz_number = input1.nextInt();
Random rand = new Random();
for (int i=0; i<quiz_number ; i++){
   System.out.println("*************************");
   System.out.println("You are in Quiz"+" "+(i+1)+" !!!");
   System.out.println("*************************"+"\n");
for (int j=0; j<ques_number ; j++){
   small_number = rand.nextInt(small_number+1);
   large_number = rand.nextInt(large_number+1);
   System.out.println("Enter the sum of two numbers : "+small_number+" "+large_number);
output1 = input1.nextInt();
sum = large_number + small_number;
if(sum==output1){
System.out.println("You are correct !!!");
}
else {
System.out.println("You are wrong !!! The correct SUM is :"+sum);
}
}
}
}
}

Here is the output of the program :

Add a comment
Know the answer?
Add Answer to:
Need a program in java that creates a random addition math quiz The program should ask...
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
  • Need a program in java that creates a random addition math quiz The program should ask...

    Need a program in java that creates a random addition math quiz The program should ask the user to enter the following The smallest and largest positive numbers to be used when generating the questions - The total number of questions to be generated per quiz - The total number of the quiz's to create

  • Write a program which gives an easy mathematics quiz. The program should display two random numbers...

    Write a program which gives an easy mathematics quiz. The program should display two random numbers which are to be added together, like this: 117 + 213 ----- The program should ask the user to enter their answer. If the answer is correct, the user should be congratulated. If the answer is wrong, the right answer should be displayed and the user should be scolded. Don't forget to: Generate random numbers Ask the user if they want to be tested...

  • Write a MIPS math quiz program in MARS. The program should start with a friendly user...

    Write a MIPS math quiz program in MARS. The program should start with a friendly user greeting. From there, it should generate a random arithmetic problem. Your program will need to generate three random things: the first and second operand and the operator to use. Your program should generate random positive integers no greater than 20 for the operands. The possible operators are +, -, * and / (division). The user should be prompted for an answer to the problem....

  • Create a program using the Random class and While loops in Java. The program should generate...

    Create a program using the Random class and While loops in Java. The program should generate a random number from 50 through 100. The loop should add the five random numbers generated. On each iteration of the loop the program should print out the number generated, how many numbers have been generated thus far, and the sum so far. On the last iteration, the printout should say the The final total is.... Teach comment the last time I did it:...

  • Using Java IDE: Write an application that asks elementary students a set of 10 math problems...

    Using Java IDE: Write an application that asks elementary students a set of 10 math problems ● First ask the user for a level and a problem type. ● You need to validate the level and problem type and loop until the user enters a correct one. ● There should be 3 levels. Level 1 operands would have values in the range of 0-9, level 2 operands would have values in the range of 0-99, and level 3 operands would...

  • This program needs to be in JAVA language. Also, I need to create my own LinkedList...

    This program needs to be in JAVA language. Also, I need to create my own LinkedList class, I can not use the Java LinkedList Library. Please read all aspects of the program, it needs to display 200 random numbers that are 5 digits long sorted from smallest to largest. I can not use Collection(s) or packages libraries. Should only need: import java.util.Random; import java.util.Scanner; Please provide output screenshots after the code. Thank you! You are going to create a Linked...

  • Python please Create a menu-driven modular program so user can take a 10-question math quiz, Addition...

    Python please Create a menu-driven modular program so user can take a 10-question math quiz, Addition or subtraction, at specified difficulty level. Easy(1-digit), Intermediate(2-digit), and Hard(3-digit). After a quiz, display the quiz type and level, and number of correct questions user answered.

  • (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the...

    (For Python program)   Write a program that fulfills the functionalities of a mathematical quiz with the four basic arithmetic operations, i.e., addition, subtraction, multiplication and integer division. A sample partial output of the math quiz program is shown below. The user can select the type of math operations that he/she would like to proceed with. Once a choice (i.e., menu option index) is entered, the program generates a question and asks the user for an answer. A sample partial output...

  • This is a Java text only program. This program will ask if the user wants to...

    This is a Java text only program. This program will ask if the user wants to create a music playlist. If user says he or she would like to create this playlist, then the program should first ask for a name for the playlist and how many songs will be in the playlist. The user should be informed that playlist should have a minimum of 3 songs and a maximum of 10 songs. Next, the program will begin a loop...

  • In Python 3, Write a program that reads a set of floating-point values. Ask the user...

    In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...

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
ADVERTISEMENT