previous | start | next

Simple Input with Scanner

    1   import java.util.Scanner;
    2   
    3   /**
    4    * Description: Finds the maximum of two input integers.
    5    * 
    6    * @author glancast
    7    * 
    8    */
    9   public class Max2 {
   10   
   11     public static void main(String[] args) {
   12       int n, m;
   13       int max;
   14       Scanner input = new Scanner(System.in);
   15   
   16       System.out.println("This program computes the maximum of two input integers");
   17       System.out.printf("\nFirst integer: ");
   18       n = input.nextInt();
   19       System.out.printf("\nSecond integer: ");
   20       m = input.nextInt();
            ...
          }
        }


previous | start | next