import java.util.*;
public class lab81
{
public static void main(String args [])
{
Scanner input = new Scanner(System.in);
System.out.print("Enter Last Name");
String LASTNAME;
LASTNAME = input.nextLine();
System.out.print("Enter First name");
String FIRSTNAME;
FIRSTNAME = input.nextLine();
System.out.print("Enter this years units");
double presentyearsUnits;
presentyearsUnits = input.nextInt();
System.out.print("Enter last year's units");
double lastyearsUnits;
lastyearsUnits = input.nextInt();
final int RANGE1 = 1000;
final int RANGE2 = 3000;
final int RANGE3 = 6000;
final int BONUS0 = 0;
final int BONUS1 = 25;
final int BONUS2 = 50;
final int BONUS3 = 100;
final int BONUS4 = 200;
int bonus;
{
if(lastyearsUnits >= presentyearsUnits)
bonus= BONUS0;
else if(presentyearsUnits <= RANGE1)
bonus= BONUS1;
else if(presentyearsUnits<=RANGE2)
bonus= BONUS2 ;
else if(presentyearsUnits <=RANGE3)
bonus= BONUS3;
else if(presentyearsUnits>=RANGE3)
bonus=BONUS4;
}
**System.out.println(("LASTNAME" + "," + "FIRSTNAME:" + "$") + bonus);**
}
}
當我編譯我不斷收到此錯誤關於未初始化的獎金。我一直在努力解決這個問題,但目前爲止我失敗了。我不知道如何初始化可變獎金。編譯器在system.out.print中突出顯示獎金。可變獎金可能尚未初始化。
不,這是一個真實的重複問題。 – Makoto 2014-10-26 23:26:53
@Makoto **和我投下的原因是?!!!!!!!! ** – 2014-10-26 23:28:14
誰說這是我壓低了你的?我所說的是,你的回答不會在你所鏈接的內容之外添加任何其他內容。 – Makoto 2014-10-26 23:31:26