Untitled
unknown
java
2 years ago
1.2 kB
8
Indexable
public static void main(String[] args) { Scanner keyedInput= new Scanner(System.in); System.out.println (" In this game you will input 10 numbers between 1 and 100. Then the program will tell you what the minimum and maximum values are!"); int[] numbers = new int[10]; int max = 0; int min = 100; int count = 0; System.out.println (" Enter 10 numbers to find the maximum and minimum number"); while (count != 10){ System.out.println("Enter Num:"); int input = keyedInput.nextInt(); if (input >= 1 && input <= 100) { numbers[count] = input; count++; } else { System.out.println ("Number out of Range"); } } for(int i = 0; i < count; i++){ if(numbers[i] > max){ max = numbers[i]; }else if(numbers[i] < min){ min = numbers[i]; } } System.out.println("The maximum of those numbers is " + max + " and the minimum of those numbers is " + min + "."); }
Editor is loading...