Random number array diagram output

Source: Internet
Author: User

Requirements: Randomly generate 10 numbers, populate an array, then display the array contents with a message box, then calculate the array elements and the results are displayed in the message box.

Design ideas: Create an array, fill in the array with random number functions, and finally output

Program Flowchart

 PackageO5;ImportJava.util.Random;Importjavax.swing.*; Public classSuiji { Public Static voidMain (string[] args) {Random Shu=NewRandom ();//Random numberString show=NewString ();//creates a string for subsequent text output        inta[]=New int[10];//Create an array        intJi=0;  for(inti=0;i<10;i++) {A[i]=shu.nextint (100); intJ=i+1; Show+ = "Array" +j+ "number is:" +a[i]+ "\ n"; Ji+=A[i]; } Show+ = "Array elements and for:" +ji; Joptionpane.showmessagedialog (NULL, show, "Random number", Joptionpane.information_message); }}

Simple summary: Random function randomness ()

Random number array diagram output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.