Professional Documents
Culture Documents
Activity 4, BAA-BSME1
Activity 4, BAA-BSME1
Baa BSME-1
Computer Engineering Department
Laboratory Activity Form
Course ES084
Description
Make a C program and draw the flowchart that prompts a customer to order 5 types of viand
with a corresponding price. Note: A 12% Value Added Tax will be charged to every customer.
The teller will also input the amount to be paid by the customer. Output the amount to be paid
by the customer as well as the change (if ever the amount given is more than the amount to be
paid.
Remarks
START
Flowchart:
Total amount to be
paid: 842.24
amount to be paid:
1000
Change: 157.76
END
C Program:
#include<stdio.h>
struct viand
{
char vnd [20];
float prc;
};
int main()
{
struct viand v[6];
int x;
float pay,chg,tot=0;
for(x=1;x<6;x++)
{
printf("Enter name of viand %d: ",x);
scanf("%s",v[x].vnd);
printf("Enter price of viand %d: ",x);
scanf("%f",&v[x].prc);
tot += v[x].prc;
printf("\n");
}
tot=tot+(tot*0.12);
printf("\nTotal Amount to be paid: %0.2f",tot);
printf("\n\nPlease enter amount to be paid: ");
scanf("%f",&pay);
chg=pay-tot;
printf("\nChange is: %0.2f", chg);
return 0;
}