1 Ocak 2015 Perşembe

RepeatAddition(Guess Game)

import java.util.*;

public class RepeatAddition{
public static void main(String args[]){
int i=(int)(Math.random()*100);
int j=(int)(Math.random()*100);

Scanner input=new Scanner(System.in);

System.out.println("What is " + i +"+"+ j +"?");

int answer=input.nextInt();

while(i + j != answer){
System.out.println("Wrong answer try again.What is " + i+ "+" + j + "?");
answer=input.nextInt();
}
System.out.println("Correct answer");


}

}

Hiç yorum yok:

Yorum Gönder