Pages

Wednesday, October 12, 2011

1. Create a simple POS program that will compute the quantity order by the customer of a food store. Kindly refer to the sample output below:

#include<stdio.h>
#include<conio.h>
#define s scanf
#define p printf



int main()
{
     int q, total, choice, b, h, c, spag, cash, ch;
    char ans;
    p("*************************************");
    p("\n*        Jobee Food House           *");
    p("\n*************************************");
    p("\n*    Value Meal             Price   *");
    p("\n*************************************");
    p("\n* 1 - Burger, Fries w/Drinks    59  *");
    p("\n* 2 - Hotdog w/Drinks           59  *");
    p("\n* 3 - 1pc Chicken w/Drinks      89  *");
    p("\n* 4 - 2pc Chicken w/Drinks      125 *");
    p("\n* 5 - Spaghetti w/Drinks        59  *");
    p("\n*************************************");
    p("\nEnter Choice:");
    s("%d",&choice);
    switch(choice)
    {
                  case 1:
            p("Enter Quantity:");
            s("%d", &q);
            b = 59;
           
            p("Upgrade [y/n]:");
            s("%s",&ans);
           
            if(ans == 'y')
              {
                   total = q * (b + 15);
    }   
                  
            else
           
            if(ans == 'n')
           
            total = q * b;
            p("Your total bill is:%d", total);
            p("\nEnter Cash:");
            s("%d", &cash);
            ch = cash - total;
            p("Change is:%d", ch);
            break;
           
           
                     case 2:
            p("Enter Quantity:");
            s("%d", &q);
            h = 59;
           
            p("Upgrade [y/n]:");
            s("%s",&ans);
           
            if(ans == 'y')
              {
                   total = q * (h + 15);
    }   
                  
            else
           
            if(ans == 'n')
           
            total = q * h;
            p("Your total bill is:%d", total);
            p("\nEnter Cash:");
            s("%d", &cash);
            ch = cash - total;
            p("Change is:%d", ch);
            break;
           
                           case 3:
            p("Enter Quantity:");
            s("%d", &q);
            c = 89;
           
            p("Upgrade [y/n]:");
            s("%s",&ans);
           
            if(ans == 'y')
              {
                   total = q * (c + 15);
    }   
                  
            else
           
            if(ans == 'n')
           
            total = q * c;
            p("Your total bill is:%d", total);
            p("\nEnter Cash:");
            s("%d", &cash);
            ch = cash - total;
            p("Change is:%d", ch);
            break;
           
          
                              case 4:
            p("Enter Quantity:");
            s("%d", &q);
            c = 125;
           
            p("Upgrade [y/n]:");
            s("%s",&ans);
           
            if(ans == 'y')
              {
                   total = q * (c + 15);
    }   
                  
            else
           
            if(ans == 'n')
           
            total = q * c;
            p("Your total bill is:%d", total);
            p("\nEnter Cash:");
            s("%d", &cash);
            ch = cash - total;
            p("Change is:%d", ch);
            break;
           
           
                                case 5:
            p("Enter Quantity:");
            s("%d", &q);
            spag = 59;
           
            p("Upgrade [y/n]:");
            s("%s",&ans);
           
            if(ans == 'y')
              {
                   total = q * (spag + 15);
    }   
                  
            else
           
            if(ans == 'n')
           
            total = q * c;
            p("Your total bill is:%d", total);
            p("\nEnter Cash:");
            s("%d", &cash);
            ch = cash - total;
            p("Change is:%d", ch);
            break;
            }
    getch();
    return 0;
}

No comments:

Post a Comment