/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package whilepkg; import java.io.BufferedReader; import java.io.InputStreamReader; /** * * @author Student */ class WhileCount { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here String strLine =""; int numToCount; BufferedReader in = new BufferedReader (new InputStreamReader(System.in)); System.out.println("Enter a number to count to between 0 and 10;"); try { strLine =in.readLine(); } catch (Exception e){ System.out.println("Error;" +e.toString());} numToCount = Integer.parseInt(strLine); if ((numToCount>0)&& (numToCount<11)){ int i = 1; while (i<=numToCount) { System.out.println(i);i++; } } else System.out.println("That number was not between 0 and 10"); } }