โปรแกรมคำนวณส่วนลด (หากลูกค้าเป็นครู) และภาษีการขาย และค้นหายอดรวมการขาย ฉันได้รับข้อผิดพลาดต่อไป:
[คำเตือน] การเปรียบเทียบระหว่างตัวชี้และจำนวนเต็ม [เปิดใช้งานโดยค่าเริ่มต้น]
#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);
}
if (something) {
มันจะไม่เกิดขึ้นอีก. - person Elazar   schedule 27.06.2013