Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

EXPLAIN THIS CODE EACH LINE

 

#include <stdio.h>
#include<string.h>
int main()
{
    char name[20];
    int meal,quantity;
    int drink,quantity2;
    char choose_meal[30] = "";
    int meal_price;
    float drink_price, orderPrice;
    char choose_drink[30] = "";
    float cash, change;
    
    printf("--------------------Marry's Fast Food--------------------");
    printf("\n");
    printf("Enter your name: ");
    scanf("%s", name);
    printf("Hello %s!\n", name); 
    
        printf("\n\nWhat would you like to order?\n");
        printf("------------------------MEALS------------------------\n\n");
        printf("[1] 1 pc. Chicken Joy....................Php 76.00\n");
        printf("[2] 1 pc. w/Jolly spaghetti..............Php 99.00\n");
        printf("[3] pc. Spaghetti........................Php 55.00\n");
        printf("[4] pc. Burger steak w/rice..............Php 85.00\n");
        printf("[5] pc. Burger...........................Php 30.00\n\n");
        
        printf("Choose a number for your meal: ");
        scanf("%d", &meal);
        printf("Quantity: ");
        scanf("%d", &quantity);
        
        printf("-----------------------DRINKS-----------------------\n\n");
        printf("[1] Coke.................................Php 15.20\n");
        printf("[2] Sprite...............................Php 15.25\n");
        printf("[3] Royal................................Php 15.30\n");
        printf("[4] Pineapple............................Php 20.25\n");
        printf("[5] Iced Tea.............................Php 20.25\n\n");
       
        printf("Choose a number for your drink: ");
        scanf("%d", &drink);
        printf("Quantity: ");
        scanf("%d", &quantity2);
    
        if(meal==1){
            strcpy(choose_meal,"Chicken Joy");
            meal_price = 76;
        }
        else if(meal==2){
            strcpy(choose_meal,"w/Jolly spaghetti");
            meal_price = 99;
        }
        else if(meal==3){
            strcpy(choose_meal,"Spaghetti");
            meal_price = 55;
        }
        else if(meal==4){
            strcpy(choose_meal,"Burger steak w/rice");
            meal_price = 85;
        }
        else{
            strcpy(choose_meal, "Burger");
            meal_price = 30;
        } 
        if(drink==1){
            strcpy(choose_drink, "Coke");
            drink_price = 15.20;
        }
        else if(drink==2){
            strcpy(choose_drink,"Sprite");
            drink_price = 15.25;
        }
        else if(drink==3){
            strcpy(choose_drink, "Royal");
            drink_price = 15.30;
        }
        else if(drink==4){
            strcpy(choose_drink, "Pineapple");
            drink_price = 20.50;
        }
        else{
            strcpy(choose_drink, "Iced Tea");
            drink_price = 20.75;
        }
        printf("---------------------ITEM ORDERED---------------------\n\n");
        printf("%s.....................Php %d x %d = %d",choose_meal,meal_price,quantity,meal_price*quantity);
        printf("\n");
        printf("%s.....................Php %f x %d = %f",choose_drink,drink_price,quantity2,drink_price*quantity2);
         
        orderPrice = meal_price*quantity+drink_price*quantity2;
        
        printf("\n");
        printf("Total amount is %f",orderPrice );
        printf("\nCash: " );
        scanf("%f", &cash);
    
        if (orderPrice <= cash )
        {
            printf("Change: %f", cash-meal_price*quantity+drink_price*quantity2);
            printf("\n\n");
            printf("---------------------------------------------------\n\n");
            printf("             THANK YOU ENJOY THE MEAL!              \n\n");
            printf("---------------------------------------------------\n");
            scanf("%f", &change);
        }
        else
        {
            printf("Please give enough money.");
        }

    return 0;
}

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education