プログラムは、割引 (顧客が教師の場合) と消費税を計算し、売上合計を見つけます。エラーが発生し続けます:
[警告] ポインタと整数の比較 [デフォルトで有効]
#include <stdio.h>
#include <math.h>
#define SALES_TAX .05
#define DISCOUNT_LOW .10
#define DISCOUNT_HIGH .12
#define DISCOUNT_LIMIT .100
int main(void)
{
double purchase_total;
double discount;
double discounted_total;
double sales_tax;
double total;
int teacher;
FILE* output_file;
/* request inputs */
printf("Is the customer a teacher (y/n)?");
scanf("%d", &teacher);
printf("Enter total purchases.");
scanf("%lf", &purchase_total);
/* calculations for teacher */
if (teacher == "y");
{/*calculate discount (10% or 12%) and 5% sales tax */
/* purchase total less than 100 */
if (purchase_total < 100)
{
/* calculate 10% discount */
discount = purchase_total * DISCOUNT_LOW;
discounted_total = purchase_total - discount;
}
/*purchase total greater than 100 */
else
{ /* calculate 12% discount */
discount = purchase_total * DISCOUNT_HIGH;
discounted_total = purchase_total - discount;
}
printf("Total purchases $%f\n", purchase_total);
printf("Teacher's discount (12%%) %fs\n", discount);
printf("Discounted total %f\n", discounted_total);
printf("Sales tax (5%%) %f\n", sales_tax);
printf("Total $%f\n", total);
}
/* calculation for nonteacher */
if (teacher =="n");
{
/* calculate only 5% sales tax */
sales_tax = purchase_total * sales_tax;
total = purchase_total + sales_tax;
printf("Total purchases $%f\n", purchase_total);
printf("Sales tax (5%%) %f\n", sales_tax);
printf("Total $%f\n", total);
}
return (0);
}