类,接口或枚举预期错误 [英] Class, interface, or enum expected error

查看:177
本文介绍了类,接口或枚举预期错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经尝试了一切我可以想到的来修复我的错误,但我完全失败了。我不断得到一个类,接口或枚举预期错误。我缺少什么?

  import java.until。*; 
public class FutureValues {
public static final Scanner CONSOLE = new Scanner(System.in);

public static void main(String [] args){
System.out.println(JENNIFER ADAME编写的实验3);
System.out.println();
//声明变量
double p;
double r;
double y;
double f

System.out.print(输入当前值:);
double p = console.nextDouble();
System.out.print(输入利率:);
double r = console.nextDouble();
System.out.print(输入年数:);
double y = console.nextDouble();
double f = compoundInterest(p,r,y);
System.out.print(未来值为+ f);
}

public static double compoundInterest(double p,double r,double y){
double f = p * Math.pow(((1 + r)/ 100) ,y);
return f;
}
}
}

如果有人可以帮助真棒!

解决方案

最后添加一个大括号'}',只需删除



如果今后想保护这些错误,请考虑正确格式化代码(使用Ctrl + shift + f进行eclipse,Alt + shift + f为netbeans)


I have tried just about everything I can think of to fix my error but I;m completely stumped. I keep getting a "class, interface, or enum expected" error. What am I missing?

import java.until.*;
public class FutureValues {
public static final Scanner CONSOLE = new Scanner(System.in);

public static void main(String[] args) {
System.out.println("Lab 3 written by JENNIFER ADAME");
System.out.println();
//declare variables
double p;
double r;
double y;
double f;

System.out.print("Enter present value: ");
double p = console.nextDouble( );
System.out.print("Enter interest rate: ");
double r = console.nextDouble( );
System.out.print("Enter number of years: ");
double y = console.nextDouble( );
double f = compoundInterest(p, r, y);
System.out.print("The future value is" + f);
}

public static double compoundInterest (double p, double r, double y) {
    double f = p * Math.pow(((1 + r) / 100), y); 
    return f;
   }
}
}

If anyone could help that would be awesome!

解决方案

You are adding one extra brace '}' at the end...just remove it

If wanna keep safe from these kind of errors in future,consider formatting your code properly.(Use Ctrl+shift+f for eclipse and Alt+shift+f for netbeans)

这篇关于类,接口或枚举预期错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆