Code:
#include <stdio.h>
#include <conio.h>
main()
{
int x;
float a,b,c,total,amount,change;
do{
clrscr();
gotoxy(31,3);
printf("CASHIERING SYSTEM\n");
gotoxy(35,4);
printf("MAIN MENU\n");
gotoxy(20,8);
printf("1. Value Meal 1 (Hotdog, Rice, Milk)");
gotoxy(20,10);
printf("2. Value Meal 2 (Chicken, Rice, Softdrink)");
gotoxy(20,12);
printf("3. Value Meal 3 (Footlong, Fries, Softdrink)");
gotoxy(20,14);
printf("4. Value Meal 4 (Porkchop, Rice, IceTea)");
gotoxy(20,16);
printf("5. Exit");
gotoxy(20,19);
printf("PLEASE ENTER A CHOICE: ");
scanf("%d",&x);
clrscr();
switch (x)
{
case 1:
gotoxy(25,6);
printf("You Selected Value Meal 1 (Hotdog, Rice, Milk)\n");
gotoxy(25,7);
printf("Please Enter price for each item");
printf("\nHotdog:");
scanf("%f",&a);
printf("\nRice:");
scanf("%f",&b);
printf("\nMilk:");
scanf("%f",&c);
total=a+b+c;
printf("\nTotal payable: %.2f", total);
do{
printf("\nAmount Tendered: ");
scanf("%f",&amount);
if(total>amount)
printf("Tendered Amount is not enough!\n");
}while(amount<total);
change=amount-total;
printf("\nChange: %.2f", change);
break;
case 2:
gotoxy(25,6);
printf("You Selected Value Meal 2 (Chicken, Rice, Softdrink)\n");
printf("Please Enter price for each item");
printf("\nChicken:");
scanf("%f",&a);
printf("\nRice:");
scanf("%f",&b);
printf("\nSoftdrink:");
scanf("%f",&c);
total=a+b+c;
printf("\nTotal payable: %.2f", total);
do{
printf("\nAmount Tendered: ");
scanf("%f",&amount);
if(total>amount)
printf("Tendered Amount is not enough!\n");
}while(amount<total);
change=amount-total;
printf("\nChange: %.2f", change);
break;
case 3:
gotoxy(25,6);
printf("You Selected Value Meal 3 (Footlong, Fries, Softdrink)\n");
printf("Please Enter price for each item");
printf("\nFootlong:");
scanf("%f",&a);
printf("\nFries:");
scanf("%f",&b);
printf("\nSoftdrink:");
scanf("%f",&c);
total=a+b+c;
printf("\nTotal payable: %.2f", total);
do{
printf("\nAmount Tendered: ");
scanf("%f",&amount);
if(total>amount)
printf("CTendered Amount is not enough!\n");
}while(amount<total);
change=amount-total;
printf("\nChange: %.2f", change);
break;
case 4:
gotoxy(25,6);
printf("You Selected Value Meal 4 (Porkchop, Rice, IceTea)\n");
printf("Please Enter price for each item");
printf("\nPorkchop:");
scanf("%f",&a);
printf("\nRice:");
scanf("%f",&b);
printf("\nIcetea:");
scanf("%f",&c);
total=a+b+c;
printf("\nTotal payable: %.2f", total);
do{
printf("\nAmount Tendered: ");
scanf("%f",&amount);
if(total>amount)
printf("Tendered Amount is not enough!\n");
}while(amount<total);
change=amount-total;
printf("\nChange: %.2f", change);
break;
case 5:
exit();
default:
printf("OUT OF RANGE!"); /--this here will not show unless I type 55(diff no.)5ect...--/
break;
}
}
while(x>5);
getch();
}
And as for the repeated codes, I'm sorry but I'm not sure how to do a return for it or call it so that in a way, I won't have to repeat my codes. I'm very much new to this so I'm not catching up well D;