【发布时间】:2015-05-18 20:39:15
【问题描述】:
你们中的任何人都可以帮助我完成我正在做的这个程序吗?我正在尝试编译它,但无法弄清楚它发生了什么。有两个 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 个错误...有人可以解释它们的含义吗?提前谢谢!
MonthExe.java:7:错误:表达式的非法开始 public int curYear = input.nextInt();
MonthExe.java:8:错误:表达式的非法开始 public int catNum;
MonthExe.java:22:错误:预期为“.class” for ( int i = 0; int
MonthExe.java:27:错误:预期为“.class” for (int j = 1; int
MonthExe.java:28: 错误: '.class' 预期 for (int k = 1; int
【问题讨论】:
标签: java