Advertisement
IronPingu

java problem

Apr 14th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. //
  2. class Phone {
  3.   public static void main(String args[]) {
  4.    
  5.     String numbers[][] = {
  6.        { "Tom", "555-3322" },
  7.        { "Mary", " 555-8976" },
  8.        { "Jon", "555-1037" },
  9.        { "Rachel", "555-1400" }
  10.      };
  11.      
  12.      int i;
  13.      
  14.      if(args.length < 2)
  15.        System.out.println("Usage: java Phone <name>");
  16.      else {
  17.          for(i=0; i<numbers.length; i++) {
  18.             if(numbers[i][0].equals(args[1])) {
  19.               System.out.println(numbers[i][0] + ": " + numbers[i][1]);
  20.               break;
  21.             }
  22.             if(i == numbers.length-1);
  23.               System.out.println("Name not found.");
  24.                  }
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement