提问人:E.schneider 提问时间:10/22/2023 最后编辑:Andrej IstominE.schneider 更新时间:10/22/2023 访问量:31
我的代码中的错误表明非法修饰符和语法错误,“VariablesDeclarators”
Errors in my code that indicates illegal modifier and syntax error, "VariablesDeclarators"
问:
import java.util.Scanner;
public class Rectangle {
private static double setLength1 = 0;
private static double setWidth1 = 0;
public static void main(String[] args){
// TODO Auto-generated method stub
{
Scanner scan = new Scanner(System.in);
System.out.println(" Today we`ll find the dimensions of a rectangle."); }
public setLength1(double setLength1);
{
double setlength1;
System.out.println("What is the length: ");
Scanner scan;
setLength1 = scan.nextDouble();
return setLength1;
}
public setWidth1(double setWidth1);
{
double setWidth1;
System.out.println("What is the Width: ");
Scanner scan;
setWidth1 = scan.nextDouble();
return setWidth1;
}
double getArea;
{
return setWidth1 * setLength1;
}
double getPerimeter;
{
return 2*(setWidth1+setLength1);
}
}
}
我最初试图用 double 替换 public,但遇到了软件的建议,将 public static void 替换为 public static double。在第 14 行和第 22 行,我添加了括号并添加了 (double seWidth1) 和 (double setLength1)。以下操作会给我带来令牌“public”的语法错误,此令牌之后的预期记录,语法错误,插入“RecordBody”以完成 RecordDeclaration,令牌“public”上的语法错误,此令牌之后预期的记录以及语法错误,插入“RecordBody”以完成第 14 行的 RecordDeclaration。
答: 暂无答案
评论
main