hi,
im busy writing a c program that will allow a shop keeper to enter item prices, check if items are vat or not, calculate vat as well as check if they are members and print out reciepts etc but with all my else statements there is this error where it says "syntax error c2143 missing ; before { but i cant put in a ; because it will make the statement empty! please help!!!
here is the code:
/* this program will allow user to enter price, check if its a VAT item or not, calculate tax if VAT,
calculate final bill, check if customer is a member, and if so calculate discount, and calculate any
change due.*/
#include <stdio.h>
#include <conio.h>
int main()
{ /* declaring and initializing variables*/
double vat = 0.10;
double mem_discount = 0.05;
double item_price;
double tax = 0;
double total_tax = 0;
double subtotal = 0;
double final_bill = 0;
double mem_final_bill = 0;
double money_paid;
double change_due;
double discount = 0;
int member;
int non_member;
char vat_item;
char nonvat_item;
char y;
char n;
printf("welcome to De Corner Variety Shop\n");
printf("enter item price, type -1 to end\n");
scanf("%lf", &item_price);
while (item_price != -1) /*while loop to allow user to enter as many items as they want and to enter a sentinel value when finished*/
{
subtotal += item_price; /*calculates running subtotal of all goods*/
printf("enter y if item is a VAT item and n if item is a non vat item\n");
scanf("%c", &vat_item);
scanf("%c", &nonvat_item);
if (vat_item == y)
{
tax = item_price * vat; /* calculates the vat owed on item*/
total_tax += tax; /* calculates the total tax of all goods*/
} // end if statement
} // end while loop
final_bill = subtotal + total_tax;
printf(" the final bill before discount (if applicable) is %.2lf\n", final_bill);
printf("enter 1 if customer is a member, 2 if a non member\n");
scanf("%d", &member);
scanf("%d", &non_member);
if (member == 1)
{
discount = final_bill * mem_discount;
mem_final_bill = final_bill - discount;
printf("the total is $ %.2lf", mem_final_bill);
printf("how much did the member pay?\n");
scanf("%lf", &money_paid);
if (money_paid > mem_final_bill)
{
change_due = money_paid - mem_final_bill;
printf("$ %.2lf is owed to the customer\n", change_due);
printf(" thank you and have a great day!\n");
}
Code:
else (money_paid == mem_final_bill)
{
printf("no change is owed to the customer\n");
printf("thank you and have a great day!\n");
}
}// end if statement
Code:
else(non_member == 2)
{
printf("the total is $ %.2lf\n", final_bill);
printf("how much did the customer pay?\n");
if (money_paid > final_bill)
{
change_due = money_paid - final_bill;
printf("$ %.2lf is owed to the customer\n", change_due);
printf(" thank you and have a great day!\n");
}
Code:
else (money_paid == final_bill)
{
printf("no change is owed to the customer\n");
printf("thank you and have a great day!\n");
}
} // end else statement
getchar();
return 0;
} // end main function
any help really appreciated!!!