Games Tebak Angka max 5 tebakan

June 6, 2010 at 11:57 am Leave a comment

public static void main(String[] args) throws IOException {

BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

int[] InputAngka= new int[11];

int x=0;

int AngkaRahasia = (int)(Math.random()*((10-0+1)+0));

System.out.println(“Tebak angka x (angka 0 sampai 10) :”);

do{

if (x<=4)

{

System.out.print(“Masukkan Angka Prediksi Anda “+ (x+1) +”: “);

InputAngka[x]= Integer.parseInt(br.readLine());

if (AngkaRahasia!=InputAngka[x])

{

System.out.println(“Prediksi Anda SALAH”);

}else

{

System.out.println(“Prediksi Anda Benar”);

System.out.println(“Angka rahasia : ” + AngkaRahasia);

System.out.println(“Prediksi Anda”);

for (int y=0;y<=x;y++)

{

System.out.print(InputAngka[y]+”\t”);

}

}

}else

{              System.out.println(“Anda KALAH, Maksimal prediksi 5 kali”);

System.out.println(“Angka rahasia : ” + AngkaRahasia);

System.out.println(“Prediksi Anda”);

for (int y=0;y<=x;y++)

{

System.out.print(InputAngka[y]+”\t”);

}

InputAngka[x]=AngkaRahasia;}

x+=1;

}while(AngkaRahasia!=InputAngka[x-1]);

}

}

Advertisement

Entry filed under: Uncategorized. Tags: .

HaLLow Menentukan Password

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


 

June 2010
M T W T F S S
« Jan    
 123456
78910111213
14151617181920
21222324252627
282930  

Pages

Top Posts

  • None

Recent Posts


Blogger Ngalam



helga indra:



Follow

Get every new post delivered to your Inbox.