Want more features on Pastebin? Sign Up, it's FREE!
Guest

For Loop Game

By: a guest on Aug 7th, 2012  |  syntax: Java  |  size: 0.46 KB  |  views: 3,736  |  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(String randomValue=Long.toString(Math.round(Math.random()*100)), numberGuessed, message="";
  2.         !message.equals("YOU WIN!");
  3.         System.out.println("Pick a number from 1 to 100"),
  4.                 numberGuessed=(new java.util.Scanner(System.in).nextLine()),
  5.                 message = numberGuessed.equals(randomValue) ? "YOU WIN!"
  6.                         : Integer.parseInt(numberGuessed)>Integer.parseInt(randomValue) ?
  7.                                 "Your number is too big!" : "Your number is too small!",
  8.                 System.out.println(message)
  9. );
clone this paste RAW Paste Data