Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
1.4 kB
4
Indexable
Never
import java.util.Scanner;

public class MaxMinAssignment {
        
    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){   
            int input = keyedInput.nextInt(); 
            if (input >= 1 && input <= 100){ 
                numbers[count] = input;  
                count++; 
            } 
            else if (input == -1){ 
                break; 
            } 
            else { 
                System.out.println ("Number out of Range"); 
            }
        
        }
        for (int i= 0; i< 10; i = i + 1) {  
            numbers[i] = keyedInput.nextInt();
        } 
        
        for (int i= 0; i< 10; i = i + 1) { 
            if (numbers[i] > max) max = numbers[i];
            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 + "."); 
               
            }
        }