Question

In: Other

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

Solutions

Expert Solution

Here is the code for above problem in Java:

import java.util.Scanner;
import java.util.Random;

public class Main{
public static void main(String []args){
int correct=0;
Scanner input=new Scanner(System.in);
System.out.println("Enter your name: ");
String name=input.nextLine();
System.out.println("Welcome "+name+" ,Please answer the following questions: ");
  
System.out.println("Smallest number to be used in quiz: ");
int min=input.nextInt();
  
System.out.println("Largest number to be used in quiz: ");
int max=input.nextInt();
  
System.out.println("Total number of questions in a quiz: ");
int totalques=input.nextInt();
  
System.out.println("Total number of quizzes to create: ");
int totalquizzes=input.nextInt();
  
Random r = new Random();
for(int i=0;i correct=0;
System.out.println("Lets start the quiz: ");
for(int j=0;j   
int r1=r.nextInt((max - min) + 1) + min;
int r2=r.nextInt((max - min) + 1) + min;
int r3=r1+r2;
System.out.print(r1 + " + " + r2 + " = ");
int GuessRandomNumberAdd = input.nextInt();
if (GuessRandomNumberAdd == r1 + r2){
System.out.println("Correct!");
correct++;
  
}else{
  
System.out.println("Wrong!");
System.out.println("The correct answer is " + r3);

}
  
  
}
  
double percentage = (correct * 100)/totalques;
System.out.println("The percentage is " + percentage);
System.out.println("**********************************************************");
}
  
  
}
}


Related Solutions

Program a math quiz on Python Specifications: - The program should ask the user a question...
Program a math quiz on Python Specifications: - The program should ask the user a question and 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. - the program should use three functions, one function to generate addition questions, one for subtraction questions, and one for multiplication questions. - the program should store the questions and...
java program Create a program that creates and prints a random phone number using the following...
java program Create a program that creates and prints a random phone number using the following format: XXX-XXX-XXXX. Make sure your output include the dashes.  Do not let the first three digits contain an 8 or 9 (HINT: do not be more restrictive than that) and make sure that the second set of three digits is not greater than 773. Helpful Hint:   Think though the easiest way to construct the phone number. Each digit does do not have to be determined...
Exercise Overview Implement a Java program that creates math flashcards for elementary grade students. User will...
Exercise Overview Implement a Java program that creates math flashcards for elementary grade students. User will enter his/her name, the type (+, -, *, /), the range of the factors to be used in the problems, and the number of problems to work. The system will provide problems, evaluate user responses to the problems, score the problems, and provide statistics about the session at the end. Functional Requirements User enters name at the beginning of a session. System covers four...
Design and write a Python 3.8 program that gives and grades a math quiz. The quiz...
Design and write a Python 3.8 program that gives and grades a math quiz. The quiz will give 2 problems for each of the arithmetic operations: +, -, *, /, and %. First, two addition problems will be presented (one at a time) with random numbers between 1 and 20. Then two subtraction problems, multiplication, division and modulus. For division use // and do floor division; for example: for 10//3, the answer should be 3. For an example of the...
C++ polymorphism. Create a program that issues a quiz through the terminal. The quiz will ask...
C++ polymorphism. Create a program that issues a quiz through the terminal. The quiz will ask a variety of C++ questions to the user and prompt them for a response. The response will differ based on the type of question, such as true or false, multiple-choice, or fill in the blank. Part 1: Designing the Quiz Design this program using a polymorphic vector of questions. Create a Question base class that will serve to point to three different derived classes:...
Complete the following program. This program should do the following: 1. Creates a random integer in...
Complete the following program. This program should do the following: 1. Creates a random integer in the range 10 to 15 for variable: allThreads, to create a number of threads. 2. Creates a random integer for the size of an ArrayList: size. 3. Each thread obtains a smallest number of a segment of the array. To give qual sized segment to each thread we make the size of the array divisible by the number of threads: while(size%allThreads != 0)size++ 4....
Write a Java program that creates an array with 20 random numbers between 1 and 100,...
Write a Java program that creates an array with 20 random numbers between 1 and 100, and passes the array to functions in order to print the array, print the array in reverse order, find the maximum element of the array, and find the minimum element of the array. The prototype of the methods: public static void printArray(int arr[]) public static void printArrayReverse(int arr[]) public static int searchMax(int arr[]) public static int searchMin(int arr[]) Sample output: Random Array: [17 67...
In Java, I need a program that will ask a user to input how many tests...
In Java, I need a program that will ask a user to input how many tests they want the average of. For example, It needs to ask the user how many tests would you like the average of? When the user enters the amount of tests they want the average score of, the program needs to give them that many test scores to input. Then with the average, determine what their grade is, if 90-100=A if 80-90 = B etc....
You do not need to import the Math class into your Java program to use methods...
You do not need to import the Math class into your Java program to use methods or constants in it. Group of answer choices True False
Write a java program (use value returning method) that gives simple math quizzes. The program should...
Write a java program (use value returning method) that gives simple math quizzes. The program should display two random integers from 1 to 100 that are to be added, such as:    47 + 29 The program allows the user to enter the answer. If the answer is correct, display “congratulations”. If the answer is incorrect, the program should show the correct answer. Your result should look like, for example:    47 + 29 Enter your answer: 1 Wrong, the right answer...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT