出现break outside switch or loop
大家好,我是一个在国外学习的留学生。由于没有编程的基础,所以遇到了这个问题不知道该怎么解决,这是第一次遇到,试了好久也还是不行,请知道我的错误是怎么回事的朋友受累帮我一下,谢谢。以下是我出现错误的代码:
import java.util.Scanner;
public class averageTemperature
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int day;
int month;
int year;
double maximumTemperature;
double minimumTemperature;
double averageTemperature ;
System.out.print("Type the day month year ");
day = keyboard.nextInt();
month = keyboard.nextInt();
year = keyboard.nextInt();
if (( year > 2010) |(year <=0))
{
System.out.println("I don't know about that year!");
break;
}
System.out.print("Please type the maximum temperature:");
maximumTemperature = keyboard.nextInt();
System.out.print("Please type the minimum temperature:");
minimumTemperature = keyboard.nextInt();
averageTemperature = (maximumTemperature + minimumTemperature)/2;
System.out.println("The average temperature in " +day +"/" +month +"/" +year + "is " + averageTemperature);
}
}
上面红色部分在编译的时候说:
javac averageTemperature.java
averageTemperature.java:23: break outside switch or loop
break;
大家好心,帮帮我,谢谢大家了。
[ 本帖最后由 qq282918963 于 2009-11-16 18:34 编辑 ]