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

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:...
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....
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...
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
The JAVA program should do the following: –Ask the user for how many lines of text...
The JAVA program should do the following: –Ask the user for how many lines of text they wish to enter –Declare and initialize an array of Strings to hold the user’s input –Use a while loop to prompt for and read the Strings (lines of text) from the user at the command line. Typically, this would be a 'for' loop since we know the number of times to execute the loop based upon the number supplied by the user, but...
Input, output, and math Draw a diagram for a program that: 1. Creates a variable called...
Input, output, and math Draw a diagram for a program that: 1. Creates a variable called tspBakingSoda, stores 1 in it. 2. Creates a variable called tspBakingPowder, stores 0.5 in it. 3. Creates a variable called cupsButter, stores 1 in it. 4. Creates a variable called cupsWhiteSugar, stores 1.5 in it. 5. Creates a variable called totalEggs, stores 1 in it. 6. Ask the user "how many batches?", store in a variable called batches. 7. Multiply tspBakingSoda by batches 8....
Write a Java Program to place a pizza ordering program. It creates a pizza ordered to...
Write a Java Program to place a pizza ordering program. It creates a pizza ordered to the specifications that the user desires. It walks the user through ordering, giving the user choices, which the program then uses to decide how to make the pizza and how much the cost of the pizza will be. Note: Use dialog boxes for communicating with the user. Remember to use the JOptionPane class which is the graphical user interface (GUI) and Comments that are...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT