当前位置: 首页 > 知识库问答 >
问题:

.类预期的和非法的表达式

柳俊彦
2023-03-14

你们谁能帮我做这个节目吗?我试图编译它,但不知道它发生了什么。有两个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个错误······有人能解释一下他们的意思吗?提前感谢!

共有1个答案

轩辕庆
2023-03-14

不能在方法内部声明public变量。删除关键字public

 类似资料:
  • 问题内容: 我当我执行以下节点的代码在控制台错误 错误: 我正在使用Angular Js,它的文件夹结构像下面这样 我在这里想念什么? 问题答案: 这段代码: 告诉Express,无论浏览器要求什么,您的服务器都应返回。因此,当浏览器请求诸如或的JavaScript文件时,您的服务器返回的内容(以开头),这会导致JavaScript错误。 回调中的代码应查看请求以确定要发回的文件,和/或您应使用带

  • 问题内容: 我一直在关注Sass教程。由于某些原因,尽管Sass文件无法正确生成css。终端说css是无效的,但我敢肯定不是。我也尝试过更改它,以防万一出现问题… 我做错了什么? Sass版本:Sass 3.1.10 错误信息: .sass文件内容: 问题答案: 根据您的错误消息(),我可以告诉您正在使用扩展名的Scss文件。将文件名更改为。 Sass和Scss使用两种不同且不兼容的语法。

  • 为什么我会得到:非法的表达式开始-公共静态int noOfLetters(String str){error?我如何修复它?

  • 请帮忙。我犯了很多错误。 sub2.cpp:在函数'int main()'中:sub2.cpp:11: 14:错误:从'const char*'到'char'的无效转换[-fpermissive]sub2.cpp:12: 14:错误:从'const char*'到'char'的无效转换[-fpermissive]sub2.cpp:16: 17:错误:在'const'之前预期的主表达式sub2.cp

  • 我知道使用regex来解析html是不可取的,但这是我想先尝试的解决方案。 我正在努力匹配 以及这些单词之间的任何字符或空格 在以下字符串中: 我使用的正则表达式是: 我知道答案?在'is'阻止我的正则表达式与最后一个p标记中的'How is'匹配之前。但我不知道应该在开头放什么来阻止比赛从第一个p标签的“发生了什么”开始 我正在查看来自https://regex101.com/r/kZWYR7/