我一直在尝试为我的一个班级完成这个最小硬币项目,但Netbeans仍然说“在MinCoins项目中找不到mincoins.MinCoins类。”这是我到目前为止所做的:
package mincoins;
import java.util.Scanner;
public class MinCoins
{
public static int main(String[] args)
{
int change = 0;
int quarters = 0;
int dimes = 0;
int nickels = 0;
int pennies = 0;
//creates a copy of Scanner class
Scanner in = new Scanner(System.in);
System.out.println("Please enter amount of change(1-99)");
change = in.nextInt();
System.out.println("Change:" + change);
//loop
while (change > 25)
{
System.out.println(change - 25);
quarters = quarters + 1;
return quarters;
}
//new loop
while (change > 10)
{
System.out.println(change - 10);
dimes = dimes + 1;
return dimes;
}
//new loop
while (change > 5)
{
System.out.println(change - 5);
nickels = nickels + 1;
return nickels;
}
//new loop
while (change > 1)
{
System.out.println(change - 1);
pennies = pennies + 1;
return pennies;
}
System.out.println("Quarters=" + quarters);
System.out.println("Dimes=" + dimes);
System.out.println("Nickels=" + nickels);
System.out.println("Pennies=" + pennies);
return change;
}//end of main
}//end of class
我该如何解决?
答案 0 :(得分:2)
替换这个:
public static int main(String[] args)
这个
public static void main(String[] args)
main方法应该返回void而不是整数...