写一个可以用于超市收银系统的C语言程序
时间: 2024-06-12 21:04:55 浏览: 16
#include <stdio.h>
int main() {
int item_code, quantity;
float price, total = 0;
char choice;
printf("Welcome to Supermarket Billing System\n");
do {
printf("Enter Item Code: ");
scanf("%d", &item_code);
printf("Enter Quantity: ");
scanf("%d", &quantity);
switch(item_code) {
case 1:
price = 25.5;
break;
case 2:
price = 15.25;
break;
case 3:
price = 10.5;
break;
case 4:
price = 5.75;
break;
default:
printf("Invalid Item Code\n");
continue;
}
total += price * quantity;
printf("Do you want to add more items? (y/n): ");
scanf(" %c", &choice);
} while(choice == 'y' || choice == 'Y');
printf("Total Bill: Rs. %.2f\n", total);
return 0;
}
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)