我有一些需要帮助的代码。我是一名 AP CS 学生(而且是入门),所以请不要评判我。
// name:
//
// program: CoinsTester
//
// purpose:
public class CoinsTester {
public static void main(String[] args) {
//create a new Coins object named money and pass it the amount of cents as a parameter
//***** STUDENTS NEED TO COMPLETE ******
Coins();
Coins money = new Coins();
// call the correct method in the Coins class to find your answer
//***** STUDENTS NEED TO COMPLETE ******
money.calculate();
}
}
// name:
//
// program: CoinsTester
//
// purpose: This class accepts a certain number of monetary change.
// The output is a list of the number of quarters, dimes, nickels,
// and pennies that will make that amount of change with the least
// number of coins possible. This is a skeleton that will be finished
// by the students
public class Coins {
//private variable to store the only attribute of a "Coins" object - how many cents the
// user wants to find change for.
private int myChange;
//constructor that accepts an initial value for the private data member
public Coins(int change) {
myChange = change;
}
// the method calculate will
// 1. use modular and regular division to determine the quantity of each type of coin
// 2. prints the quantity of the coins needed to make the entered amount
public void calculate(){
int quarters=25, dimes=10, nickels=5, pennies=1;
int temp1, temp2, temp3, temp4;
int remainquar1, remaindime2, remainnick3, remainpenn4;
//variable declarations to hold the values needed for different coin types
// make sure you use descriptive identifiers!
//***** STUDENTS NEED TO COMPLETE ******
// calculations for the various coin types
//***** STUDENTS NEED TO COMPLETE ******
// output statements, formatted as shown on specs
//***** STUDENTS NEED TO COMPLETE ******
}
}
所以事情就是这样,我为我格式不正确的代码道歉。所以当我运行它时,它说 Coins money = new Coins() 找不到代码的构造函数。我需要帮助来创建合适的对象。这里的事情是我必须为“CoinsTester”创建一个对象,然后它告诉我我没有链接到该对象的构造函数。我现在真的找不到解决方案。有人能给我关于如何为 CoinsTester 类创建构造函数的提示吗?