私はこのウェブサイトでこれらのエラーの両方を調べ、提案された変更に対応するようにコードを変更しようとしましたが、私のコードでは機能しませんでした. 課題の半分ほどしか終わっていないので完全ではありませんが、正しく構築されないため、これまでに行ったことを確認できません。ありがとうございました!
#include <stdio.h>
//int CheckMoney(double *payment, double item_cost); //compares the amount the user has deposited to the price of item selected. It returns 1 if the amount is at least enough to cover the cost, 0 if there is not enough.
//void GetMoney(double *payment, double item_cost, char selection); //calls CoinMenu function to collect money from the user and CheckMoney function to keep comparing the deposited amount to the item cost.
//void GetChange(double *payment, double item_cost, double *change); //calculates the amount of change to be returned
void CoinMenu(double *payment);
void Quit(char *again);
void GetCost(char selection, double *item_cost);
void Menu(char *selection);
// Displays the list of snack items and prompts for the user’s choice
void Menu(char *selection)
{
printf("Welcome to the AAA vending machine, where your wishes could come true for less than $2");
printf("/nWhich one of our delicious snacks would you like to sink your teeth into?");
printf("/nP – Potato Chips $1.25");
printf("/nS - Snickers Bar $1.35");
printf("/nT – Pop Tart $0.95");
printf("/nC – Cookies $1.50");
printf("/nB – Brownie $1.75");
printf("/nN – Nuts $1.40");
printf("Enter your delicious selection here: ",*selection);
scanf(" %c", &*selection);
//determine cost of selection
GetCost(*selection, 0);
}
//sets the cost of the purchase based on value in selection
void GetCost(char selection, double *item_cost)
{
if(selection=='P'||'p')
{
*item_cost=1.25;
}
else if(selection=='S'||'s')
{
*item_cost=1.35;
}
else if(selection=='T'||'t')
{
*item_cost=0.95;
}
else if(selection=='C'||'c')
{
*item_cost=1.50;
}
else if(selection=='B'||'b')
{
*item_cost=1.75;
}
else if(selection=='N'||'n')
{
*item_cost=1.40;
}
else
{
printf("That is not a valid selection, have a nice day!");
return;
}
}
//displays menu of coins and gets user input of the coins deposited
void CoinMenu(double *payment)
{
printf("Please deposit your money by the following numbers:");
printf("/n1 - $5.00");
printf("/n2 - $2.00");
printf("/n3 - $1.00");
printf("/n4 - $0.25");
printf("/n5 - $0.10");
printf("/n6 - $0.05");
printf("/n7 - $0.01");
printf("/nAmount deposited: ");
scanf(" %c", &*payment);
}
void Quit(char *again)
{
printf("Would you like to buy another snack?");
printf("/nEnter Y for yes or N for no: ", *again);
if(*again=='N'||'n')
{
return;
}
else if(*again=='Y'||'y')
{
void Menu(char *selection);
}
}