我一直在尝试为我的一个班级完成这个Minimum Coins项目,但是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


我如何解决它?

最佳答案

替换为:

public static int main(String[] args)


为了这

 public static void main(String[] args)


main方法应返回void而不是整数...

08-26 13:09