SHARE
TWEET

For Loop Game

a guest Aug 7th, 2012 4,490 Never
  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. );
RAW Paste Data
Top