C Program to write Farmer Program Logic.
How does this program work?
- This code helps to how to write Farmer Program logic.
Here is the code
int main()
{
int b,B,k,a,w,c,j,n;
float i=0,r,t=0,s=0,p=0,m;
printf("Welcome to FDC program\n");
printf("Please Enter the Number of Acres you have Harvested:\n");
scanf("%d",&a);
printf("Enter the Loan sanctioned by the Bank for one Acre :\n");
scanf("%d",&b);
B = a * b;
printf("Loan sanctioned for %d",a);
printf("Acres is %d\n",B);
printf(" Number of months taken to Harvest :\n");
scanf("%d",&n);
printf("Enter the rate of Interest:\n");
scanf("%f",&r);
i=(n*B*r)/100;
printf("Interest:%f\n",i);
t=i+B;
printf("Total Amount is:%f\n",t);
printf("Enter the amount you got at the end of the Harvest:");
scanf("%f",&m);
if(m>t)
{
p = m - t;
printf("The profit you got:%f\n",p);
printf("Choose any option\n");
printf("1.paddy\n 2.tomato\n 3.wheat\n 4.grains\n");
scanf("%d",&k);
if(p>B/2&&k==1)
printf("You are a smart card member\n");
else
printf("Your are not a smart card member\n");
}
else if(m==0)
{
printf("Enter the way of loss\n 12.Thufan\n 13.Floods\n");
scanf("%d",&w);
if(w==12)
{
printf("You have lost majorly\n we are going to give you complete compensation\n we are going to give you a cash of 5000 and two rice bags per month to compensate the loss\n");
}
else if(w==13)
{
printf("We are going to compensate the complete loss\n");
}
else
printf("Wrong Choice");
}
else if(m < t)
{
printf("You have lost through viruses and personal defects\n");
printf("choose an option to select season\n");
printf("1.Kharif\n 2.Rabi\n");
scanf("%d",&c);
printf("choose option to select the crop harvested\n");
printf("11.Paddy\n 22.Tomato\n 33.Wheat\n 44.Grains\n");
scanf("%d",&j);
if(a>=10)
{
switch(c)
{
case 1:
{
switch(j)
{
case 11:
{
s=(t*50)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
case 22:
{
printf("You will not recieve amount for this \n");
printf("No compensation for this crop\n");
}
case 33:
{
s=(t*30)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
case 44:
{
s=(t*20)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
default:
printf("Wrong option");
break;
}
}
break;
case 2:
{
switch(j)
{
case 11:
{
s=(t*60)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
case 22:
{
s=(t*10)/100;
printf("The amount you recieve is:%f\n",s);
}
case 33:
{
s=(t*40)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
case 44:
{
s=(t*30)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
default:
printf("Wrong option");
break;
}
}
break;
default:
printf("Wrong option");
break;
}
}
else if(a>0&&a<10)
{
switch(c)
{
case 1:
{
switch(j)
{
case 11:
{
s=(t*5)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
case 22:
{
printf("You will not recieve amount for this \n");
printf("no compensation for this crop\n");
}
case 33:
{
s=(t*3)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
case 44:
{
s=(t*2)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
default:
printf("Wrong option");
break;
}
}
break;
case 2:
{
switch(j)
{
case 11:
{
s=(t*6)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
case 22:
{
s=(t*1)/100;
printf("The amount you recieve is:%f\n",s);
}
case 33:
{
s=(t*4)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
case 44:
{
s=(t*3)/100;
printf("The amount you recieve is:%f\n",s);
}
break;
default:
printf("Wrong option");
break;
}
break;
}
default:
printf("Wrong option");
break;
}
printf("Please collect your compensation from ur respective banks\n");
}
else
printf("wrong choice\n");
}
else
printf("no profit and no loss\n");
}