Home > Java > javaTutorial > Detailed explanation of four arithmetic operations methods for implementing random output of 300 questions in Java

Detailed explanation of four arithmetic operations methods for implementing random output of 300 questions in Java

高洛峰
Release: 2017-03-09 18:49:50
Original
1987 people have browsed it

This article explains in detail the four arithmetic methods of java to implement random output of 300 questions

package demo;

import java.util.Random;

public class math {
       
    public static void main(String[] args) {
           
        String[] operate=new String[]{"+","-","×","÷"};
           int[] numbers=new int[1000];
           
           for(int i=1;i<=1000;i++){
           numbers[i-1]=i;
       }
          Random r=new Random();
      
          for(int i=0;i<300;i++){
      
              System.out.println(numbers[r.nextInt(1000)]+operate[r.nextInt(4)]+numbers[r.nextInt(1000)]+"=");
       }
      }
     }
Copy after login

The above is the detailed content of Detailed explanation of four arithmetic operations methods for implementing random output of 300 questions in Java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template