java代码提示找不到符号_java - 编译Java代码时找不到符号 - 堆栈内存溢出

这个问题已经在这里有了答案:

import acm.program.*;

public class Exercise1 extends Program{

public void run(){

int i;

for(i=1; i<=2; i++){

if(i==1){

int s = readInt("Give a number for the current day, 0:Sunday, 1:Monday, 2:Tuesday, 3:Wednesday, 4:Thursday, 5:Friday, 6:Saturday :");

String dayName1 = DayName(s);

int day1 = readInt("Give the number of the current day:");

int month1 = readInt("Give the number of the current month:");

int year1 = readInt("Give the current year:");

boolean flag = LeapYearCheck(year1);

int yearDays1 = YearDays(year1);

int monthDays1 = MonthDays(month1);

}

else{

int s = readInt("Give a number for your desired day, 0:Sunday, 1:Monday, 2:Tuesday, 3:Wednesday, 4:Thursday, 5:Friday, 6:Saturday :");

String dayName2 = DayName(s);

int day2 = readInt("Give the number of a day of your choice:");

int month2 = readInt("Give the number of a month of your choice:");

int year2 = readInt("Give your desired year:");

boolean flag = LeapYearCheck(year2);

int yearDays2 = YearDays(year2);

int monthDays2 = MonthDays(month2);

}

}

if(year1>=year2){

int sumC = yearDays1 + monthDays1 + day1;

int sumG = yearDays2 + monthDays2 + day2;

int sum;

if( sumG > sumC )

sum = sumG - sumC;

else if( sumC > sumG )

sum = sumC - sumG;

println("It has been " + sum + " Days since " + day2 + "/" + month2 + "/" + year2 + " " + dayName2);

}

else

println("This date has not come yet.");

}

public String DayName(int s){

switch (s){

case 0:return("Sunday");

case 1:return("Monday");

case 2:return("Tuesday");

case 3:return("Wednesday");

case 4:return("Thursday");

case 5:return("Friday");

case 6:return("Saturday");

}

}

private boolean LeapYearCheck(int Y){

boolean flag;

if(Y/4 == 0 && Y/100 != 0 || Y/400 == 0 && Y/100 !=0)

return flag = true;

else

return flag = false;

}

private int YearDays(int y){

if( flag == true)

return 366;

else

return 365;

}

private int MonthDays(int m){

if( m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)

return 31;

else if(m!=2)

return 30;

else if(flag==true)

return 29;

else

return 28;

}

}

每次我尝试在命令行上进行编译时,我都会收到14种错误,所有错误类型均为**error: cannot find symbol 。 例如:

Exercise1.java82:错误:找不到其他符号if(flag == true)。

符号^也位于f下方。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值