Simple Fast Food Cashiering
A simple fast food cashiering demonstrate the Else If Structures. I used the logical operator AND && to compare the two conditions.
OUTPUT
#include <stdio.h>
int main()
{
int drinks, food;
int qty1, qty2;
float totalfood, totaldrinks;
printf("\t Fast Food Cashiering \n");
printf("-------------------FOOD------------------\n");
printf(" [ 1 ] - BURGER\t\tPhp 25.00\n");
printf(" [ 2 ] - SPAGHETTI\t\tPhp 30.00\n");
printf(" [ 3 ] - CHICKEN W/ RICE\tPhp 75.00\n");
printf("-----------------------------------------\n");
printf(" \nSelect your food order: ");
scanf("%d", &food);
printf("Enter Quantity: ");
scanf("%d", &qty1);
printf("\n------------------DRINKS-----------------\n");
printf(" [ 1 ] - COCA COLA\t\tPhp 15.00\n");
printf(" [ 2 ] - ICED TEA\t\tPhp 20.00\n");
printf("-----------------------------------------\n");
printf(" \nSelect your drinks order: ");
scanf("%d", &drinks);
printf("Enter Quantity: ");
scanf("%d", &qty2);
system("pause");
if (food == 1 && drinks == 1)
{
printf("\n--------------------ITEMS ORDERED--------------------\n");
printf("BURGER\t\t\t\tPhp 25.00 x %d = %.2f\n", qty1, 25.0 * qty1);
printf("COCA COLA\t\t\tPhp 15.00 x %d = %.2f\n", qty2, 15.0 * qty2);
printf("-----------------------------------------------------\n");
totalfood = qty1 * 25;
totaldrinks = qty2 * 15;
printf("Total:\t\t\t\t\t Php%.2f\n", totalfood + totaldrinks);
}
else if (food == 1 && drinks == 2)
{
printf("\n--------------------ITEMS ORDERED--------------------\n");
printf("BURGER\t\t\t\tPhp 25.00 x %d = %.2f\n", qty1, 25.0 * qty1);
printf("ICED TEA\t\t\tPhp 20.00 x %d = %.2f\n", qty2, 20.0 * qty2);
printf("-----------------------------------------------------\n");
totalfood = qty1 * 25;
totaldrinks = qty2 * 20;
printf("Total:\t\t\t\t\t Php%.2f\n", totalfood + totaldrinks);
}
else if (food == 2 && drinks == 1)
{
printf("\n--------------------ITEMS ORDERED--------------------\n");
printf("SPAGHETTI\t\t\tPhp 30.00 x %d = %.2f\n", qty1, 30.0 * qty1);
printf("COCA COLA\t\t\tPhp 15.00 x %d = %.2f\n", qty2, 15.0 * qty2);
printf("-----------------------------------------------------\n");
totalfood = qty1 * 30;
totaldrinks = qty2 * 15;
printf("Total:\t\t\t\t\t Php%.2f\n", totalfood + totaldrinks);
}
else if (food == 2 && drinks == 2)
{
printf("\n--------------------ITEMS ORDERED--------------------\n");
printf("SPAGHETTI\t\t\tPhp 30.00 x %d = %.2f\n", qty1, 30.0 * qty1);
printf("ICED TEA\t\t\tPhp 20.00 x %d = %.2f\n", qty2, 20.0 * qty2);
printf("-----------------------------------------------------\n");
totalfood = qty1 * 30;
totaldrinks = qty2 * 20;
printf("Total:\t\t\t\t\t Php%.2f\n", totalfood + totaldrinks);
}
else if (food == 3 && drinks == 1)
{
printf("\n--------------------ITEMS ORDERED--------------------\n");
printf("CHICKEN W/ RICE\t\t\tPhp 75.00 x %d = %.2f\n", qty1, 75.0 * qty1);
printf("COCA COLA\t\t\tPhp 15.00 x %d = %.2f\n", qty2, 15.0 * qty2);
printf("-----------------------------------------------------\n");
totalfood = qty1 * 75;
totaldrinks = qty2 * 15;
printf("Total:\t\t\t\t Php%.2f\n", totalfood + totaldrinks);
}
else if (food == 3 && drinks == 2)
{
printf("\n--------------------ITEMS ORDERED--------------------\n");
printf("CHICKEN W/ RICE\t\t\tPhp 75.00 x %d = %.2f\n", qty1, 75.0 * qty1);
printf("ICED TEA\t\t\tPhp 20.00 x %d = %.2f\n", qty2), 20.0 * qty2;
printf("-----------------------------------------------------\n");
totalfood = qty1 * 75;
totaldrinks = qty2 * 20;
printf("Total:\t\t\t\tPhp%.2f\n", totalfood + totaldrinks);
}
else
{
printf("\n---------------ITEMS ORDERED-------------\n");
printf("INVALID MEAL AND DRINKS\n");
printf("-----------------------------------------\n");
}
system("pause");
return 0;
}
Simple Fast Food Cashiering
Reviewed by code-dev
on
2:00 PM
Rating:
No comments: