Question

use java thanks

Write a program that prompts a user to enter number of Math question that she wishes the system to generate. The system will

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

Dear Student ,

As per the requirement submitted above , kindly find the below solution.

Here a new java program with name "Main.java" is created, which contains following code.

Main.java :

import java.util.*;//importing package
import java.util.Random;
public class Main //Main class
{ //main method
   public static void main(String[] args) {
       //creating object of scanner class
       Scanner sc=new Scanner(System.in);
       //asking user to enter number of questions
       System.out.print("How many Math question you want to create? ");
       int num=sc.nextInt();//reading input
       //display details
       System.out.println(num+" questions have been created as below : ");
   //creating object of Random class
   Random random=new Random();
       //using for loop to generate number of questions
       for(int i=1;i<=num;i++)
       {
       int op=random.nextInt(5-1)+1;//this will generate number 1 to 4
       int num1=random.nextInt(100-1)+1;//generate number between 1 to 100
       int num2=random.nextInt(100-1)+1;//generate number between 1 to 100
       //using switch loop to generate operations
       switch(op)
       {
       case 1:System.out.println(i+")"+num1+" + "+num2);
       break;//used to come out of case
       case 2:System.out.println(i+")"+num1+" - "+num2);
       break;//used to come out of case
       case 3:System.out.println(i+")"+num1+" x "+num2);
       break;//used to come out of case
       case 4:System.out.println(i+")"+num1+" / "+num2);
       break;//used to come out of case
       }
       }
   }
}

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

Output : Compile and Run above program to get the screen as shown below

Screen 1 :Main.java,screen asking number of questions

input How many Math question you want to create? 10

Screen 2 :Screen showing questions

input How many Math question you want to create? 10 10 questions have been created as below 1)18 17 2)12 x 8:3 3) 50 56 4) 59

Screen 3 :

How many Math question you want to create? 4 4 questions have been created as below: 1) 50 87 2) 46 - 20 3)34 80 4)76+70 . .

NOTE : PLEASE FEEL FREE TO PROVIDE FEEDBACK ABOUT THE SOLUTION.

Add a comment
Know the answer?
Add Answer to:
use java thanks Write a program that prompts a user to enter number of Math question that she wishes the system to gene...
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
  • This program is to ask the user N number of math (using only +, -, *,...

    This program is to ask the user N number of math (using only +, -, *, and /) questions. Once the program start it asks the user to enter how many questions will be asked (N, which is between 3-10). Then, the program asks N questions to the user. Each question will be one of four math operations (+, -, *, and /). The operation and operands will be selected randomly in your program.Operand are “unsigned short” between 0 and...

  • C++ Exercise#1: Reverse list Write a program that prompts the user to enter a list of...

    C++ Exercise#1: Reverse list Write a program that prompts the user to enter a list of 10 integer numbers, list. Your program should replace each multiples of 4 number with 0 in list. Produces the output as in the sample input/output below Sample input/output C:AUsers 10064 Documents My Courses 14111161Spring 20151Lab.. ease enter ist ers: 1 he input list after processing: 0 34 45 65 0 99 85 10 30 rocess returned 0 (0x0) execution time: 34.398 s ress key...

  • 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....

  • Its java class pratice  problem (Geometry: point in a rectangle?) Write a program that prompts the user...

    Its java class pratice  problem (Geometry: point in a rectangle?) Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (0, 0) with width 10 and height 5.  For example, (2, 2) is inside the rectangle and (6, 4) is outside the rectangle. (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is less than or equal to10 / 2 and...

  • MATLAB QUESTION 8) Create a program that first prompts the user to enter any two numbers....

    MATLAB QUESTION 8) Create a program that first prompts the user to enter any two numbers. Then prompt the user again to input as many numbers as they choose. Stop the program by inputting-1. Then, display the largest number and second largest number in the command window once the user kills the program. The built-in max function cannot be used. The figure below is an example of what the command window should look like when the code is ran. First...

  • Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds

    Problem 1.Write a program that prompts the user to enter the number of milliseconds and converts the milliseconds to a string hours:minutes:seconds. The program should use the convertMillismethod with the following header:public static String convertMillis(long millis)For example, convertMillis(5500) returns the string 0:0:5, convertMillis(100000) returns the string 0:1:40, andconvertMillis(555550000) returns the string154:19:10.Problem 2. (Count occurrence of numbers)Write a program that reads integers between 1 and 100 and counts the occurrence of each (you should store the numbers in an array). Output...

  • Math Problem Generator Your job will be to write a C++ program to teach math to...

    Math Problem Generator Your job will be to write a C++ program to teach math to school children. Your program will accomplish this by showing sets of math problems to the user and allowing them to enter an answer. The program should tell the user if they are correct and should continue providing additional questions. The program will keep track of correct and incorrect answers. The questions should use random numbers and should be simple enough math problems that someone...

  • Write a Java program called Flying.java that, firstly, prompts (asks) the user to enter an input...

    Write a Java program called Flying.java that, firstly, prompts (asks) the user to enter an input file name. This is the name of a text file that can contain any number of records. A record in this file is a single line of text in the following format: Num of passengers^range^name^manufacturer^model where: Num of passengers is the total number of people in the plane. This represents an integer number, but remember that it is still part of the String so...

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • Adv. Java program - create a math quiz

    Create a basic math quiz program that creates a set of 10 randomly generated math questions for the following operations:AdditionSubtractionMultiplicationDivisionModuloExponentThe following source files are already complete and CANNOT be changed:MathQuiz.java (contains the main() method)OperationType.java (defines an enumeration for valid math operations and related functionality)The following source files are incomplete and need to be coded to meet the indicated requirements:MathQuestionable.javaA Random object called RANDOM has already been declared and assigned, and you must not change this assignment in any way.Declare and assign an interface integer called MAX_SMALL and assign it the...

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