title: printing the largest number from a while loop, when 10 numbers are inputted from the keyboard
body: <p>Every time my output prints out the last number given through the Scanner as the largest number. This program needs to be modified in a way, that it scans through the numbers I input and prints out the largest number.</p>
  
  <p>P.S this is not school work, its just coding in my spare time.</p>
  
  <pre><code>import java.util.Scanner;
  
  public class FindTheLargestNumber {
  
      public static void main(String[] args) {
  
          int counter = 1;
          int number;
          int largest = 0;
  
          Scanner input = new Scanner(System.in);
  
          System.out.println("Enter the number: ");
          number = input.nextInt();
  
          while(counter &lt; 10)
          {
              System.out.println("Enter the number: ");
              number = input.nextInt();
  
              counter++;
  
          }
  
  
          if(number &gt; 1)
              largest = number;
  
  
          System.out.println("the largest number is " + largest);
      }
  }
  </code></pre>
  
  <p>CONSOLE:</p>
  
  <pre><code>Enter the number: 
  123
  
  Enter the number: 
  443
  
  Enter the number: 
  221
  
  Enter the number: 
  453
  
  Enter the number: 
  553
  
  Enter the number: 
  665
  
  Enter the number: 
  776
  
  Enter the number: 
  23
  
  Enter the number: 
  12
  
  Enter the number: 
  23
  
  
  output: 
  the largest number is 23
  </code></pre>
  
  <p>it should clearly print out 776, but it prints the last number I input as the largest.</p>