Pages

Wednesday, October 12, 2011

solution number 10.

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

int main()
{
    int price, x;
 
    p("Choices:\n");
    p("1.] XL\n");
    p("2.] L\n");
 
 
    p("Enter T-Shirt Size: ");
    s("%d", &x);
 
 
 
    switch(x)
 
    {
    case 1:
     
         p("Enter Price: ");
         s("%d", &price);
     
         if(price>= 500)
       
         p("You Have Discount 100!");
     
         break;
     
    
     
     
    case 2:
              p("Enter Price: ");
              s("%d", &price);
          
              if(price >= 400)
          
              p("You have Discount 50!");
          
              break;
          
     
         default:
                  p("thank you!");
              
                  break;
                  }
         getch();
         return 0;
         }

perimeter

#include<stdio.h>
#include<conio.h>

int choice,p,a,b,c,area,base, height;

int main()
{
printf("This program will get the perimeter and are of Triangle\n");
printf("Choices\n");
printf("1.] Perimeter\n");
printf("2.] Area\n");
printf("Enter Choice [1 or 2]: ");
scanf("%d",&choice);

if (choice == 1)
{
printf("Enter Side A: ");
scanf("%d",&a);
printf("Enter Side B: ");
scanf("%d",&b);
printf("Enter Side C: ");
scanf("%d",&c);
p = a + b + c;
printf("The perimeter of the area of a triangle is %d",p);
}

if (choice == 2)
{
printf("Enter Base: ");
scanf("%d",&base);
printf("Enter Height: ");
scanf("%d",&height);
area = (base * height)/2;
printf("The area of a triangle is %d",area);
}
getch();
return 0;
}

9. Write a program that will display "IT'S COLD!" if the temperature is less than 20, "IT'S HOT!" if the temperature is greater than 30, "COOL CLIMATE!" otherwise.

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

int main()
{
     int A;
    
     p("enter your temperature:");
     s("%d", &A);
     if(A<=20)
     p("IT'S COLD!");
     else if (A<=30)
     p("COOL CLIMATE!");
     else if(A>=30)
     p("IT'S HOT!");
     getch();
     return 0;
     }
    

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;
}