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