C Program to write Pharmacy Program Logic.
How does this program work?
- This code helps to how to write Pharmacy Program logic.
Here is the code
int main()
{
int a,s1,p1,t1,bill=0,b=0,br=0,m=0,s=0,ca=0,p=0,tr=0,c=0,t=0,l=0,k=0,x=0;
int y=0,q=0,w=0,e=0,r=0,z=0,sum1=0,sum4=0,sum7=0,Total=0,tax=0,boxes=0;
char n[10];
long int ph;
printf("Welcome to DR.PHARMACEUTICALS\n");
printf("Main Branches are at\n1.Vizag\n2.Hyderabad\n");
printf("Choose your Place:\n");
printf("11.Kakinada\n22.Nizamabad\n");
scanf("%d",&a);
if(a==11)
{
printf("Our nearest Branch is in Vizag\n");
printf("Enter your Name:\n");
scanf("%s",&n);
printf("Enter your Phone Number:\n");
scanf("%ld",&ph);
printf("we have a syrup namely\n 1.Benedryl\n with a limited stock of 5 boxes each\n");
printf("we have a powder namely\n 1.3M Soluprep\n with a limited stock of 5 boxes each\n");
printf("we have a tablet namely\n 1.tyroxin 25mg\n with a limited stock of 5 boxes each\n");
printf("Enter the no of boxes of Benedryl needed\n");
scanf("%d",&s1);
printf("Enter the no of boxes of Soluprep needed\n");
scanf("%d",&p1);
printf("Enter the no of boxes of tyroxin 25mg needed\n");
scanf("%d",&t1);
if(s1<=5&&s1!=0)
{
b=1;
}
else if(s1>5)
{
printf("we don't have enough stock to supply Benedryl \n");
printf("we can get it from Vizag for extra cost if wanted \n 1.yes \n 2.no\n");
scanf("%d",&l);
}
else
printf("not needed\n");
if(p1<=5&&p1!=0)
{
s=1;
}
else if(p1>5)
{
printf("we don't have enough stock to supply 3M Soluprep \n");
printf("we can get it from Vizag for extra cost if wanted \n 1.yes \n 2.no\n");
scanf("%d",&x);
}
else
printf("not needed\n");
if(t1<=5&&t1!=0)
{
tr=1;
}
else if(t1>5)
{
printf("we don't have enough stock to supply 3M Tyroxin 25 mg \n");
printf("we can get it from Vizag for extra cost if wanted \n 1.yes \n 2.no\n");
scanf("%d",&y);
}
else
printf("not needed\n");
printf("Bill Details:\n");
printf("Name:\n%s\n",n);
printf("Phone Number:\n%ld\n",ph);
printf("MEDICINES\t BOXES\t COST \n");
if(b==1)
{
sum1=s1*290;
printf("BENEDRYL\t:%d\t",s1);
printf("%d\n",sum1);
}
else
{
switch(l)
{
case 1:
{
sum1=(s1-5)*300+ 1450;
printf("BENEDRYL\t:%d\t",s1);
printf("%d\n",sum1);
}
break;
case 2:
{
sum1=s1*290;
printf("BENEDRYL\t:%d\t",s1);
printf("%d\n",sum1);
}
break;
default:
printf("wrong choice");
}
}
if(s==1)
{
sum4=p1*90;
printf("SOLUPREP\t:%d\t",p1);
printf("%d\n",sum4);
}
else
{
switch(x)
{
case 1:
{
sum4=(p1-5)*400 + 1950;
printf("SOLUPREP\t:%d\t",p1);
printf("%d\n",sum4);
}
break;
case 2:
{
sum4=p1*35;
printf("SOLUPREP\t:%d\t",p1);
printf("%d\n",sum4);
}
break;
default:
printf("wrong choice");
}
}
if(tr==1)
{
sum7=t1*20;
printf("TYROXIN\t\t:%d\t",t1);
printf("%d\n",sum7);
}
else
{
switch(y)
{
case 1:
{
sum7=(t1-5)*30 + 100;
printf("TYROXIN\t\t:%d\t",t1);
printf("%d\n",sum7);
}
break;
case 2:
{
sum7=t1*20;
printf("TYROXIN\t:%d\t",t1);
printf("%d\n",sum7);
}
break;
default:
printf("wrong choice");
}
}
Total=sum1+sum4+sum7;
boxes=s1+p1+t1;
printf("Total:\t\t:%d\t",boxes);
printf("%d\n",Total);
tax=Total/20;
printf("Tax:\t\t:\t");
printf("%d\n",tax);
bill=Total+tax;
printf("Bill:\t\t:\t");
printf("%d\n",bill);
}
if(a==22)
{
printf("Our nearest Branch is in Hyderabad\n");
printf("Enter your Name:\n");
scanf("%s",&n);
printf("Enter your Phone Number:\n");
scanf("%ld",&ph);
printf("we have a syrup namely\n 1.Benedryl\n with a limited stock of 5 boxes each\n");
printf("we have a powder namely\n 1.3M Soluprep\n with a limited stock of 5 boxes each\n");
printf("we have a tablet namely\n 1.tyroxin 25mg\n with a limited stock of 5 boxes each\n");
printf("Enter the no of boxes of Benedryl needed\n");
scanf("%d",&s1);
printf("Enter the no of boxes of Soluprep needed\n");
scanf("%d",&p1);
printf("Enter the no of boxes of tyroxin 25mg needed\n");
scanf("%d",&t1);
if(s1<=5&&s1!=0)
{
b=1;
}
else if(s1>5)
{
printf("we don't have enough stock to supply Benedryl \n");
printf("we can get it from Hyderabad for extra cost if wanted \n 1.yes \n 2.no\n");
scanf("%d",&l);
}
else
printf("not needed\n");
if(p1<=5&&p1!=0)
{
s=1;
}
else if(p1>5)
{
printf("we don't have enough stock to supply 3M Soluprep \n");
printf("we can get it from Hyderabad for extra cost if wanted \n 1.yes \n 2.no\n");
scanf("%d",&x);
}
else
printf("not needed\n");
if(t1<=5&&t1!=0)
{
tr=1;
}
else if(t1>5)
{
printf("we don't have enough stock to supply 3M Tyroxin 25 mg \n");
printf("we can get it from Hyderabad for extra cost if wanted \n 1.yes \n 2.no\n");
scanf("%d",&y);
}
else
printf("not needed\n");
printf("Bill Details:\n");
printf("Name:\n%s\n",n);
printf("Phone Number:\n%ld\n",ph);
printf("MEDICINES\t BOXES\t COST \n");
if(b==1)
{
sum1=s1*300;
printf("BENEDRYL\t:%d\t",s1);
printf("%d\n",sum1);
}
else
{
switch(l)
{
case 1:
{
sum1=(s1-10)*310+ 3000;
printf("BENEDRYL\t:%d\t",s1);
printf("%d\n",sum1);
}
break;
case 2:
{
sum1=s1*300;
printf("BENEDRYL\t:%d\t",s1);
printf("%d\n",sum1);
}
break;
default:
printf("wrong choice");
}
}
if(s==1)
{
sum4=p1*100;
printf("SOLUPREP\t:%d\t",p1);
printf("%d\n",sum4);
}
else
{
switch(x)
{
case 1:
sum4=(p1-10)*110 + 1000;
printf("SOLUPREP\t:%d\t",p1);
printf("%d\n",sum4);
}
break;
case 2:
{
sum4=p1*100;
printf("SOLUPREP\t:%d\t",p1);
printf("%d\n",sum4);
}
break;
default:
printf("wrong choice");
}
}
if(tr==1)
{
sum7=t1*30;
printf("TYROXIN\t\t:%d\t",t1);
printf("%d\n",sum7);
}
else
{
switch(y)
{
case 1:
{
sum7=(t1-10)*40 + 300;
printf("TYROXIN\t:%d\t",t1);
printf("%d\n",sum7);
}
break;
case 2:
{
sum7=t1*30;
printf("TYROXIN\t:%d\t",t1);
printf("%d\n",sum7);
}
break;
default:
printf("wrong choice");
}
}
Total=sum1+sum4+sum7;
boxes=s1+p1+t1;
printf("Total:\t\t:%d\t",boxes);
printf("%d\n",Total);
tax=Total/20;
printf("Tax:\t\t:\t");
printf("%d\n",tax);
bill=Total+tax;
printf("Bill:\t\t:\t");
printf("%d\n",bill);
}
}