Jgrasp java 26错误:应为类、接口或枚举
我正在为我的班级做一个项目,每次我尝试编译时,jGrasp中都会出现以下错误:Jgrasp java 26错误:应为类、接口或枚举,java,enums,compiler-errors,runtime-error,jgrasp,Java,Enums,Compiler Errors,Runtime Error,Jgrasp,我正在为我的班级做一个项目,每次我尝试编译时,jGrasp中都会出现以下错误: Lab 1.java:26: error: class, interface, or enum expected Module main() ^ 1 error 我已经试着在我的代码中寻找错误,但如果有人看到我忽略的错误,我就找不到它,这将非常有帮助,我将非常感谢任何能够消除错误的更正。下面是代码,您可以仔细查看它 /*问题:租金 分析、设计并编写以下应用程序: 它允许用户输入房屋租金和 计算第一个月的付款。第一个
Lab 1.java:26: error: class, interface, or enum expected
Module main()
^
1 error
我已经试着在我的代码中寻找错误,但如果有人看到我忽略的错误,我就找不到它,这将非常有帮助,我将非常感谢任何能够消除错误的更正。下面是代码,您可以仔细查看它
/*问题:租金
分析、设计并编写以下应用程序:它允许用户输入房屋租金和 计算第一个月的付款。第一个月 付款包括保证金(相当于2个月的租金) 和第一个月的租金。显示以下内容: 每月€™租金、保证金金额和最终付款
Input
User: 1. Rent amount
Given: N/A
Processing: 1. Calculate security deposit = 1 month rent * 2
2. Calculate total first month rent =
1 month rent + security deposit
Output: 1. Price for 1 month of rent
2. Price of security deposit
3. Total for first months' rent
*/
//Design
Module main()
//Declarations
Declare Real oneMonthRent = 0.0//One month rent entered by user
Declare Real securityDeposit = 0.0//2 months worth of rent
Declare Real firstMonthRent = 0.0//Security deposit + 1 month rent
//Input
Set oneMonthRent = Call getRent()//user entered
//Processing
Set securityDeposit = Call calcDeposit(oneMonthRent)//oneMonthRent + oneMonthRent
Set firstMonthRent = Call calcFirstMonthRent(oneMonthRent, securityDeposit)//oneMonthRent + securityDeposit
//Output
Call showRentAnalysis(oneMonthRent, securityDeposit, firstMonthRent)//Displays oneMonthRent, Deposit, and total first month
End Module
//Gets monthly rent cost from user
Function Real getRent()
Declare Real nRent = 0.0//local variable
Display "Enter monthly rent "
Input nRent
Return nRent
End Function
//Calculates the Security deposit
Function Real calcDeposit(Real noneMonthRent)
Declare Real ndeposit = 0.0//local variable
Set ndeposit = noneMonthRent + noneMonthRent
Return ndeposit
End Function
//Calculates total first month rent
Function Real calcFirstMonthRent(Real noneMonthRent,Real nsecurityDeposit)
Declare Real nfirstMonthRent = 0.0//local variable
Set nfirstMonthRent = noneMonthRent + nsecurityDeposit
Return nfirstMonthRent
End Function
//Displays 1 month of rent, security deposit, and final for first month
Module showRentAnalysis(Real noneMonthRent,Real nsecurityDeposit,Real nfirstMonthRent)
Display "One month worth of rent cost ", noneMonthRent
Display "Security deposit cost ", nsecurityDeposit
Display "Total for first month of rent is ", nfirstMonthRent
End Module
这看起来根本不像java代码……这不是java代码。
public class Main {
public static void main(String[] args) {
double rent = 500.50;
double securityDeposit = rent*2;
double firstMonth = rent+securityDeposit;
System.out.println(firstMonth);
}
}