자말 :
난 자바 초보자를 그리고 난이 블록에 대한 도움이 필요합니다 :
그것은 끝에 추가 득점을 얻을 해달라고 문 "만일"숫자가 처음 미만 6을 때 내가 여기있는 문제이다. 나는 문이, 내가 0의 점수를 초기화 "만일"내가 뭘 잘못 것은 두 번째에 알아,하지만 내가 어떻게 할 수있는 두 그래서이보다 높은 6을 때 문이 점수에 추가 할 수 있습니다 "만일"과 이 6 미만 때 추가하지? 임의의 숫자가 6보다 작은 경우,이 점수에 추가 할 수 없습니다. 난 내가 잘 explaning있어 알고 있지만, 시간 내 주셔서 감사하지 않습니다!
int shot;
int score = 0;
shot = rand.nextInt(11);
score += shot;
if (shot > 6) {
System.out.print("\nSHOT " + a + ".... Challenger shoots: " + shot);
}
else {
score = 0;
System.out.print("\nSHOT " + a + ".... Challenger shoots: " + "You missed the board!");
}
shot = rand.nextInt(11);
score += shot;
if (shot > 6) {
System.out.print("\nSHOT " + (++a) + ".... Challenger shoots " + shot);
}
else {
score = 0;
System.out.print("\nSHOT " + (++a) + ".... Challenger shoots: " + "You missed the board!");
}
System.out.print("\nCHALLENGER SCORE: " + score);
아빈 드 쿠마 Avinash :
당신은 그것을 할 수 있습니다
int score = 0;
int shot;
System.out.println("Shot#1:");
shot = rand.nextInt(11);
if (shot > 6) {
score += shot;
System.out.print("\nSHOT " + a + ".... Challenger shoots: " + shot);
} else {
System.out.print("\nSHOT " + a + ".... Challenger shoots: You missed the board!");
}
System.out.println("Shot#2:");
shot = rand.nextInt(11);
if (shot > 6) {
score += shot;
System.out.print("\nSHOT " + (++a) + ".... Challenger shoots: " + shot);
} else {
System.out.print("\nSHOT " + (++a) + ".... Challenger shoots: You missed the board!");
}
System.out.print("\nCHALLENGER SCORE: " + score);
의심 / 문제의 경우에 의견을 주시기 바랍니다.