-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassigament one question five.c
More file actions
35 lines (27 loc) · 986 Bytes
/
assigament one question five.c
File metadata and controls
35 lines (27 loc) · 986 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
int main() {
char anotherCustomer = 'y';
while (anotherCustomer == 'y' || anotherCustomer == 'Y') {
int numProducts;
double totalAmount = 0.0;
printf("Enter the number of products: ");
scanf("%d", &numProducts);
int i;
for (i = 0; i < numProducts; i++) {
char productName[50];
double price;
int quantity;
printf("Enter name of product %d: ", i + 1);
scanf("%s", productName);
printf("Enter price of product %d: ", i + 1);
scanf("%lf", &price);
printf("Enter quantity of product %d: ", i + 1);
scanf("%d", &quantity);
totalAmount += price * quantity;
}
printf("Total amount for this customer: %.2lf\n", totalAmount);
printf("Is there another customer? (y/n): ");
scanf(" %c", &anotherCustomer);
}
return 0;
}