Xcode の端末アプリケーションでこれを作成しましたが、エラーを修正する方法を使用します。すみません全くの初心者です。エラーがあります
void addToTotal (float cost, int quantity)
誰かが私のコードで私を助けることができますか?
//
// main.m
// ShoppingList
#import <Foundation/Foundation.h>
#include <stdio.h> //? not sure if this is correct
//Gobal variables visable from any function
//------VARIABLES
int totalItems = 0;
float totalCost = 0.0;
float salesTax = 0.0925;
//decalre the functions going to be used
// we don't need to declare main() because it's built-in
//------FUNCTIONS
void addToTotal (float cost, int quantity);
float costWithSalesTax (float price);
//------MAIN PROGRAM
int main(int argc, const char * argv[])
{
@autoreleasepool {
float budget = 10000.00;
// make a new line
printf("\n");
//set the price for each item
float laptopPrice = 1799.00;
float monitorPrice = 499.80;
float phonePrice = 199.00;
addToTotal(laptopPrice, 2);
addToTotal(monitorPrice, 1);
addToTotal(phonePrice, 4);
//display a line then the final total
printf("----------------------\n");
printf("TOTAL for %i items: $%5.2f\n\n", totalItems, totalCost);
if(totalCost < budget)
{
printf("You came in under your budget!");
}
else
{
printf("Your're over your budget. Time to talk to finance.\n\n");
}
}
// There's an error in here asking me to put ; after this method declaration.
void addToTotal (float cost, int quantity)
{
printf(" Adding %i items of the cost $%5.2f\n", quantity, cost);
// find the cost for this item by multiple costs by quantity.
// and get the real costs by applying sales tax.
float calculatedCost = cost * quantity;
float realCost = costWithSalesTax(calculatedCost);
// and this amount to the total, and increase the total number
// of items purchased
totalCost = totalCost + realCost;
totalItems = totalItems + quantity;
printf("Subtotal for %i items: $%5.2f\n", totalItems, totalCost);
}
// There's an error in here asking me to put ; after this method declaration.
float costWithSalesTax (float price)
{
// remember sales tax is a global variable
float taxAmount = price * salesTax;
float subTotal = price + taxAmount;
return subTotal;
}
}
return 0; // also this has the error "expected identifier or (" error
}