Advertisement
lol1234561

Untitled

Apr 28th, 2023
1,062
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.Scanner;
  3. public class Main {
  4.    public static void main(String[] args) {
  5.        Random rand = new Random();
  6.        Scanner scan = new Scanner(System.in);
  7.        int[] a1 = new int[10];
  8.  
  9.  
  10.         int min = 1;
  11.         int max = 100;
  12.         int top = a1[0];
  13.  
  14.        System.out.print("Array: ");
  15.  
  16.        for(int x = 0; x< a1.length; x++){
  17.             a1[x] = rand.nextInt(max-min + 1) + min;
  18.             System.out.print(a1[x] + " ");
  19.        }
  20.        System.out.println(" ");
  21.        for (int j = 0; j< a1.length; j++){
  22.            if (a1[j]>top){
  23.                top = a1[j];
  24.            }
  25.  
  26.  
  27.        }
  28.        System.out.println("The largest value is: " +
  29.                top );
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement