Welcome Guest.

1Answers

Write programs with Java, read 10 intenses from the keyboard to the array, output maximum, minimum

Asked by: Paul Davis 249 views IT March 13, 2021

Write programs with Java, read 10 intenses from the keyboard to the array, output maximum, minimum

1 Answers

  1. +5Votes  

    This basic program is best done, reference:

    public static void main (string [] args) {
    int [] a = new int [10]; // declaration An integer array
    INT I;
    Scanner sc = new scanner (system.in);
    FOR (i = 0; i <10; i ++) {
    a [ I] = sc.nextint (); // Receive the user’s input, initialize one by one by one member,
    }
    Int max, min;
    max = min = a [0]; // first take The first
    for (i = 1; I <10; i ++) {
    if (a [i]> max)
    max = a [i];
    IF (a [i] min = a [i];
    }
    system.out.printf (“maximum:% D, minimum value% D \ n”, max, min);
    }

    Rachel Rose- March 13, 2021 |