Pages

Sunday 20 November 2016

Problem 2 - While

import java.util.Scanner;
 
class WhileLoop {
  public static void main(String[] args) {
    int n;
 
    Scanner input = new Scanner(System.in);
    System.out.println("Input an integer"); 
 
    while ((n = input.nextInt()) != 0) {
      System.out.println("You entered " + n);
      System.out.println("Input an integer");
    }
 
    System.out.println("Out of loop");
  }
}


0 comments:

Post a Comment