You are on page 1of 5

Theodore C.

Baa BSME-1
Computer Engineering Department
Laboratory Activity Form

Course ES084

Course Title Computer Programming 1

Topics Covered: Sequential Programming

To implement basic I/O functions and arithmetic expressions. The use of


Objectives: integer division (/) operators and some built-in mathematical operations in
a program.

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.

Sample Output if Applicable

Remarks
START
Flowchart:

name of viand1: litson


name of viand2: sinigang
name of viand3: chopchuey
name of viand4: tinola
name of viand5: paksiw

price of viand1: 350


price of viand2: 150.75
price of viand3: 125.50
price of viand4: 75
price of viand5: 50.75

Total amount to be paid = (price of


viand1 + price of viand2 + price of
viand3 + price of viand4 + price of
viand5) *(12/100)

Total amount to be
paid: 842.24
amount to be paid:
1000

Change = Amount to be paid - Total


amount to be paid

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;
}

You might also like