Advertisement
brilliant_moves

StarColumn.java

Apr 15th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.84 KB | None | 0 0
  1. import javax.swing.*;
  2.  
  3. public class StarColumn {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         /**
  8.         *   Homework solutions!!
  9.         *
  10.         *   For high quality Open Source Java code, beginner to intermediate, search Amazon for:
  11.         *
  12.         *   "50 Java Program Source Codes" by Chris Clarke.
  13.         *
  14.         *   Also by the same author "50 More Java Source Codes".
  15.         *
  16.         *   Available in paperback and e-book.
  17.         */
  18.  
  19.         int n = 0;
  20.  
  21.         try {
  22.             // get number using pop-up dialog
  23.             n = Integer.parseInt(
  24.              JOptionPane.showInputDialog( "Enter whole number"));
  25.         }
  26.         catch (NumberFormatException e) {
  27.             System.out.println( "That's not a whole number!");
  28.         } // end try..catch
  29.  
  30.         System.out.println(); // new line
  31.         for (int i=0; i<n; i++) {
  32.             System.out.print("*");
  33.         } // end for
  34.         System.out.println(); // new line
  35.  
  36.     } // end main()
  37.  
  38. } // end class StarColumn
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement