title: How do I accept and output both Doubles and Ints in an Array?
body: <pre><code>import java.util.Scanner;
  
  public class PeopleWeights {
  
     public static void main(String[] args) {
  
       Scanner scnr = new Scanner(System.in);
  
       final int NUM_VALS = 5;
  
       int [] personsWeight = new int[NUM_VALS];
  
       int i = 0;
  
       for (i = 0; i &lt; NUM_VALS; ++i) {
       System.out.print("Enter weight " + (i + 1) + ": ");
       System.out.println();
       personsWeight[i] = scnr.nextInt();
       }
  
       double sumVal = 0.0;
  
       for (i = 0; i &lt; NUM_VALS; ++i) {
          sumVal = sumVal + personsWeight[i];
       }
  
       double avgVal = 0.0;
  
       for (i = 0; i &lt; NUM_VALS; ++i) {
          avgVal = sumVal / NUM_VALS;
       }
  
       double maxVal = 0.0;
  
       for (i = 0; i &lt; NUM_VALS; ++i) {
          maxVal = personsWeight[0];
          if (maxVal &lt; personsWeight[i]) {
             maxVal = personsWeight[i];
          }
       }
  
       System.out.println();
       System.out.println(personsWeight[1] + " " + personsWeight[2] + " " 
       + personsWeight[3] + " " + personsWeight[4] + " " + personsWeight[5]);
  //I know that this can be cleaner but this is where the 
  //problem occurs with a InputMismatchException. 
  //I know it's caused by the double being introduced 
  //but don't know how to fix it.
  
  
       System.out.println("Total weight: " + sumVal);
  
       System.out.println("Average weight: " + avgVal);
  
       System.out.println("Max weight: " + maxVal);
  
       return;
    }
  }
  </code></pre>
  
  <p>The inputs are as follows:
  236 ,
  89.5 ,
  142 ,
  166.3 ,
  93 .</p>
  
  <p>I want to handle the output numbers just as they are input. Double or Int.</p>
  
  <p>Is there anyway I can make the Array accept both types of numbers in the scanner or would I have to resort another way that it works?</p>