Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java .class应为非法表达式_Java - Fatal编程技术网

Java .class应为非法表达式

Java .class应为非法表达式,java,Java,你们谁能帮我做这个项目?我正试图编译它,但不知道它发生了什么。有两个java文件,我将只发送一个主文件,它是有问题的文件(直到现在)。这是一个计算公司每月利润的简单程序 import java.util.Scanner; public class MonthExe{ public static void main( String[] args ){ Scanner input = new Scanner( System.in ); System.out.

你们谁能帮我做这个项目?我正试图编译它,但不知道它发生了什么。有两个java文件,我将只发送一个主文件,它是有问题的文件(直到现在)。这是一个计算公司每月利润的简单程序

import java.util.Scanner;

public class MonthExe{
    public static void main( String[] args ){
        Scanner input = new Scanner( System.in );
        System.out.println( "Inform the current year..." );
        public int curYear = input.nextInt();
        public int catNum;
        String control = "n";
        while ( control = "n" ){
            System.out.println( "Inform the current month..." );
            int curMonth = input.nextInt();
            Month month = new Month( curMonth );
            month.monthMessage( curMonth );
            String control = input.next();
        }
        System.out.println( "Inform the number of arts..." );
        curArts = input.nextInt();
        System.out.println( "Inform the number of categories from the cheapest to the most expensive one..." );
        catNum = input.nextInt();
        curVals = new double[ catNum ];
        for ( int i = 0; int = catNum; i++ ){
            System.out.println( "Inform the price of the category" + ( i + 1 ) );
            curVals[i] = input.nextDouble();
        }
        Month month = new Month( curYear, curArts, curVals );
        for ( int j = 1; int = curArts; j++ ){
            for ( int k = 1; int = curVals.length; k++ ){
                System.out.println( "Inform the amount of units sold for product " + j + " and category " + k );
                int curAmount = input.nextInt();
                month.setProfit( curAmount, k );
                month.setTotalProfit( month.getTotalProfit() );
            }
        }
        month.finalMessage();
        System.out.println( "Thank you for using this software!" );
    }
}
试图编译上述程序会返回以下5个错误。。。有人能解释一下他们的意思吗?提前谢谢你

java:7:错误:表达式的开始非法 public int curYear=input.nextInt()

java:8:错误:表达式的开始非法 公共int catNum

java:22:错误:“.class”应为 对于(int i=0;int java:27:错误:“.class”应为
对于(int j=1;int您不能在方法内声明
public
变量。删除关键字
public
您不能在方法内声明
public
变量。删除关键字
public
对于错误#1和2,删除
public
关键字,您不能在方法内定义变量的范围(更多)

对于错误#3、4和5,For循环声明中的第二个表达式需要求值为布尔值。对于#3
int=catNum
应该是这样的:
i
。对于#4和5也是如此。(关于For循环的更多信息)

对于错误#1和2,请删除
public
关键字,您不能在方法内对变量进行作用域(更多)


对于错误#3、4和5,For循环声明中的第二个表达式需要计算为布尔值。For#3
int=catNum
应该是这样的:
i
。对于#4和5也是这样。(有关For循环的更多信息)

谢谢!!我忘了!谢谢!!我忘了!我把它们三个改成布尔运算符,就像你把
int
改成
I
j
k
?我把它们三个改成布尔运算符,就像你把
int
改成
I
j
k