daily pastebin goal
32%
SHARE
TWEET

epic

anakin23805 Apr 16th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top