Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 11th, 2012  |  syntax: Java  |  size: 0.39 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. for(int randomValue=(int)Math.floor(Math.random()*100)+1, numberGuessed=0;
  2.         randomValue!= numberGuessed;
  3.         System.out.println("Pick a number from 1 to 100"),
  4.                 numberGuessed=Integer.parseInt(new java.util.Scanner(System.in).nextLine()),
  5.                 System.out.println(numberGuessed==randomValue ? "You WIN!":
  6.                         (numberGuessed>randomValue? "Your number is too big!" : "Your number is too small!"))
  7. );