Advertisement
anakin23805

epic

Apr 16th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Lab7Scores {
  4.     public static void main(String[] args){
  5.         int[] userNumbers = new int[10];
  6.         int userIn = 0;
  7.         int total = 0;
  8.         int highest = 0;
  9.         int lowest = 0;
  10.         int average = 0;
  11.        
  12.         Scanner console = new Scanner(System.in);
  13.        
  14.         System.out.println("Enter a series of 10 integers between 1 and 100:");
  15.        
  16.         for(int i = 0; i < 10; i++){
  17.            
  18.             userIn = console.nextInt();
  19.             while(userIn > 100 || userIn < 0){
  20.                 System.out.println("Invalid entry. Must be between 1 and 100.");
  21.                 userIn = console.nextInt();
  22.             }
  23.             userNumbers[i] = userIn;
  24.             total += userIn;
  25.         }
  26.        
  27.         highest = userNumbers[0];
  28.         lowest = userNumbers[0];
  29.         average = total/10;
  30.         for(int i = 0; i < userNumbers.length; i++){
  31.             if(userNumbers[i] > highest){
  32.                 highest = userNumbers[i];
  33.             }
  34.             if(userNumbers[i] < lowest){
  35.                 lowest = userNumbers[i];
  36.             }
  37.            
  38.         }
  39.         System.out.println("Total:\t\t" + total);
  40.         System.out.println("Average:\t" + average);
  41.         System.out.println("Highest:\t" + highest);
  42.         System.out.println("Lowest:\t\t" + lowest);
  43.        
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement