0

私は、販売額を取り、ドルからの変化を計算するクラスのプログラムを書いています。各金種は、出力としてコインの量とともにリストされます。引数が少なすぎるため、エラーが発生して実行できませんか?

ここでVBが何を探しているのかわかりません。どんな助けでも大歓迎です。

プログラムコード:

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>

using namespace std;

// Determines how many of each coin to dispense.
void Dispenser(int, int *, int *, int *, int *);                                    



int main(void)
{
    // Change the console's background color.
    system ("color F0");

        // Declares the variables.
        double amount_paid = 1.00, amount_due;                                                             
        int amount_left, dollar_qty, quarter_qty, dime_qty, nickel_qty, penny_qty; 

    // Get user input.
    cout << "\n";
    cout << "Enter the money amount paid: $";
        cin >> amount_due;
    cin.ignore();

    // Perform calculations.
    amount_paid = amount_paid * 100 + 0.5;
        amount_due = amount_due * 100;

        amount_left = amount_paid - amount_due;
        dollar_qty = amount_left / 100;

        Dispenser (amount_left + quarter_qty + dime_qty + nickel_qty + penny_qty);

        "\n";


        // Display output.
        cout << "\nAmount of the purchase: " << fixed << setprecision(2) << showpoint        << amount_due;
        cout << "\nChange from $1.00: " << fixed << setprecision(2) << showpoint <<      amount_left;
        cout << "\n" << fixed << setprecision(2) << showpoint << dollar_qty << "      dollars";
        cout << "\n" << fixed << setprecision(2) << showpoint << quarter_qty <<       "quarters";
        cout << "\n" << fixed << setprecision(2) << showpoint << dime_qty << "dimes";
        cout << "\n" << fixed << setprecision(2) << showpoint << nickel_qty <<      "nickles";
        cout << "\n" << fixed << setprecision(2) << showpoint << penny_qty <<      "pennies";

    system("pause");
        return 0;   
}

void Dispenser(int amt_left, int *quarters, int *dimes, int *nickels, int *pennies)
{
    int    total_change, total_quarters, total_dimes, total_nickels, total_pennies;

    // Determine change amount by quantity.

    total_change = amt_left % 100;
    total_quarters = total_change / 25;
    total_change = total_change % 25;
    total_dimes = total_change / 10;
    total_change = total_change % 10;
    total_nickels = total_change / 5;
    total_change = total_change % 5;
    total_pennies = total_change;

    *quarters = total_quarters;
    *dimes = total_dimes;
    *nickels = total_nickels;
    *pennies = total_pennies;
}

エラーはこの行の「)」にあります

Dispenser (amount_left + quarter_qty + dime_qty + nickel_qty + penny_qty);
4

3 に答える 3

5
Dispenser (amount_left + quarter_qty + dime_qty + nickel_qty + penny_qty);

する必要があります

Dispenser (amount_left, quarter_qty, dime_qty, nickel_qty, penny_qty);

あなたのバージョンは実際にはすべての値を合計した 1 つの大きなパラメーターにすぎませんが、私が提供したコンマ付きのバージョンは、関数に送信される 5 つの個別のパラメーターであることを意味します。

于 2013-02-27T20:38:15.093 に答える
2
Dispenser (amount_left + quarter_qty + dime_qty + nickel_qty + penny_qty);

する必要があります

Dispenser (amount_left, &quarter_qty, &dime_qty, &nickel_qty, &penny_qty);
于 2013-02-27T20:40:11.220 に答える
2

「,」の代わりに「+」を使用しましたか?

于 2013-02-27T20:38:05.003 に答える