두 개의 숫자를 먼저 물어보고 메소드를 사용했는지 여부를 확인한 다음 마지막 숫자를 보낸 후 메소드의 결과를 출력합니다 . (네가 이기면, 잃지 않아도됩니다.)Java public static boolean method
여기를 다른 질문과 비교해 보았지만 어떻게 든 작동시킬 수는 없습니다. 메소드 외부의 메서드 내에서 luckyNumbers를 만들었고 심지어 "Big Java"를 구입했지만 지금은 붙어 있습니다.
도움말에 감사드립니다.
package wtf;
import Java.util.Scanner;
/**
*
* @author Darl
*/
public class WTF {
public static int luckyNumber;
public static int secondLuckyNumber;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Give me a number between 0 and 100 to win a prize. ");
luckyNumber = sc.nextInt();
System.out.println("Give me another number between 100 and 200.");
secondLuckyNumber = sc.nextInt();
}
public static boolean hasLuckyNumber(int luckyNumber, int min, int max){
min = 20; //all winning tickets from 20 till 60
max = 60;
if (luckyNumber > min || luckyNumber < max) {
System.out.println("Unfortunatly, no prize");
}else{
System.out.println("You've got a prize!");
}
}
public static boolean hasSecondLuckyNumber(int secondLuckyNumber, int min, int max){
min = 140; // all winning tickets from 140 till 175
max = 175;
if (secondLuckyNumber > min || secondLuckyNumber < max){
System.out.println("Sad face");
}else{
System.out.println("We've got a winner!");
}
}
}
그럼 실제 질문은 무엇입니까? – Mena
책 구입은 단지 지식을 제공하는 것이 아니라는 점에 유의하십시오. 당신의 프로그램은 무엇을하고 있다고 생각하니? 왜 네가 원하는대로 할 수 없니? –
* 작동하지 않을 수 있습니다 * - 프로그램에서 무엇을해야합니까? 실제로 무엇을합니까? 실행하면 어떤 오류가 발생합니까? – azurefrog