我想製作一個小程序,首先要求輸入兩個數字,使用方法檢查它們是否正確,然後在輸入最後一個數字後打印出方法的結果。 (是的,你贏了,沒有你輸了)。Java公共靜態布爾方法
我將此與其他問題進行了比較,但不知何故,我無法使其工作。我在方法之外製作了幸運數字,甚至購買了「大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 2014-10-07 16:01:13
請注意,購買書不僅僅會給你提供知識。你認爲你的程序在做什麼?你爲什麼不能做到你想做的事? – 2014-10-07 16:01:47
*我無法讓它工作* - 你的程序應該做什麼?它實際上做了什麼?你運行它時會得到什麼錯誤(如果有的話)? – azurefrog 2014-10-07 16:02:35