我得到这个错误缺少main()的错误
在
Bank
类未找到Main方法,请确定的主要方法为:public static void main(String[] args)
或JavaFX应用程序类必须扩展javafx.application.Application
这是我的Bank
类
public class Bank { //Bank Class to calculate the value for infrastructure of each Bank
final int N = 9; // Equal to highest number in my CQU Student ID 12029103
int cost;
public int costPerBank(int numberOfComputers) {
// Calculate the total cost for numberOfComputers entered by the user
if (numberOfComputers == 0) { // When user enters '0' or negative values
cost=0;
}
if (numberOfComputers <= 2 && numberOfComputers >= 1) { // When user enters '1' or '2'
cost=1000;
}
if (numberOfComputers > 2 && numberOfComputers<=20) { // When user enters '3' to '20'
cost=1000+((numberOfComputers-2)*400);
}
if (numberOfComputers > 20 && numberOfComputers<=100) { // When user enters '21' to '100'
cost=1000+((numberOfComputers-2)*300);
}
if (numberOfComputers > 100) { // When user enters more than '100'
cost=numberOfComputers*200;
}
return cost;
}
}
好吧,让您听起来像是在尝试运行“Bank”类......您期望做什么?显示的错误信息对我来说似乎相当清楚。 –
根据他明显缺乏的经验判断,我猜他不知道需要使用Main方法来做任何事情,等等。 – Matt
这是专业人士的Q/A网站,其中您的问题是其他程序员的宝贵资源。这不是一个WhatsApp聊天。请使用“请”,“我”,“不要”等全文,而不是“plz”,“i”,“dnt”,“whr”。 – RealSkeptic