写一个可以用于超市收银系统的C语言程序
时间: 2024-06-12 10:04:55 浏览: 135
#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;
}
阅读全文
相关推荐


















