我确定可能存在大量语法/其他错误,但我正在尝试找出它正在处理的两个错误。我对此很陌生,所以我真的不知道如何修复未声明的标识符。请注意,这#include <cs50.h>
只是 CS50 的库。
#include <cs50.h>
#include <stdio.h>
int main (void)
{
int add, fee, disc;
printf("For rate with tax and Security Deposit, type y. For 10 percent off, type n:");
string name = GetString();
if (name == y)
{
printf("PreTax Amount: ");
scanf("%d", &fee);
printf("Okay. I will add the 10 percent tax to %d.\n ", fee);
add = (1.1 * fee);
printf("Plus Tax Amount = %d\n", add);
printf("Security Deposit = 1000 dollars\n");
printf("Total = (%d + 1000)", add);
}
else if (name == n)
{
printf("PreTax Amount: ");
scanf("%d%d", &fee, &disc);
printf("Okay. I will minus the 10 percent discount to %d and then add tax.\n ", fee);
add = (0.9 * fee);
disc = (add * 1.1);
printf("Minus Discount Amount plus tax = %d\n", disc);
printf("Security Deposit = 1000 dollars\n");
printf("Total = (%d + 1000)", disc);
}
return 0;
}
错误:
ContractualHelper.c:10:17: error: use of undeclared identifier 'y'
if (name == y)
^
ContractualHelper.c:22:22: error: use of undeclared identifier 'n'
else if (name == n)
^
2 errors generated.