c program to implement a cloth showroom activities

Description


This program implements a cloth showroom bill calculation. The users can purchase either hand loom, mill cloth or both.  The discount depends on both the type of cloth and the total amount of purchase. The program uses a switch statement to find the discount for different purchases by different users. Once the discount is calculated the statement tot=amt-d; finds the final amount the user has to pay.

Program

 
#include<stdio.h>

#include<conio.h>

#include<process.h>

void main()

{

 clrscr();

 int type,i;

 float d,amt,tot,hl,ml;

 printf("Enter the cloth type 1 :handloom 2 :mill cloth 3 :both");

 scanf("%d",&type);

 if(type >3 | type<1)

 {

  exit(0);

 }

     if(type==3)

  {

  printf("enter the value of handloom & mill cloth:");

  scanf("%f%f",&hl,&ml);

  amt=hl+ml;

  goto l;

  }

 printf("\nenter the amount:");

 scanf("%f",&amt);

 l:

 i=amt/100;

 switch(i)

  {

   case 1 :

   if(type==1)

    {

    d=0;

    break;

    }

   if(type==2)

    {

    d=(amt*5)/100;

    break;

    }

   else

    {

    d=(ml*5)/200;

    break;

    }

   case 2 : if(type==1)

    {

    d=(amt*5)/100;

    break;

    }

    if(type==2)

     {

     d=(amt*7.5)/100;

     break;

     }

    else

     {

     d=((ml*5)/200)+((amt*7.5)/200);

     break;

     }

   case 3 : if(type==1)

    {

    d=(amt*7.5)/100;

    break;

    }

    if(type==2)

     {

     d=(amt*10)/100;

     break;

     }

    else

     {

     d=((ml*7.5)/200)+((amt*10)/200);

     break;

     }

   default  : if(type==1)

    {

    d=(amt*10)/100;

    break;

    }

    if(type==2)

     {

     d=(amt*15)/100;

     break;

     }

    else

     {

     d=((ml*10)/100)+((amt*15)/100);

     break;

     }

   }

 printf("\nDiscount is: %f" ,d);

 tot=amt-d;

 printf("\n Total amount is: %f",tot);

 getch();

}





No comments: