Last active
August 29, 2015 14:02
-
-
Save agungsijawir/561128e9aa5dd06d8770 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class tebakan2 { | |
public static void main(String[] args) { | |
int lariknya2[] = new int[100]; | |
int tebakan = (int) (Math.random() * (( 100 - 0) + 1)); | |
int tebakan_user = 0, mencoba_tebak = 0, lariknya2_size = lariknya2.length; | |
boolean ketebak = false; | |
BufferedReader baca_tebakan = new BufferedReader(new InputStreamReader(System.in)); | |
System.out.println("Computer Guess: " + tebakan); | |
System.out.println("Please guess from [1..100]!"); | |
for (int cb = 0; cb < lariknya2_size; cb++) | |
lariknya2[cb] = cb + 1; | |
do { | |
System.out.println("Tebakan Anda?"); | |
try { | |
tebakan_user = Integer.parseInt(baca_tebakan.readLine()); | |
} catch (IOException e) { | |
System.out.println("Error Input!"); | |
} | |
if (tebakan_user == tebakan) | |
ketebak = true; | |
else if (tebakan_user > tebakan) | |
System.out.println("Salah! Kurangi!"); | |
else if (tebakan_user < tebakan) | |
System.out.println("Salah! Lebihkan!"); | |
mencoba_tebak++; | |
} while (ketebak != true); | |
System.out.println("Selamat! Tebakan Anda benar!"); | |
System.out.println("Anda mencoba sebanyak " + mencoba_tebak + " kali."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment