Ques.
An Insurance company follows following rules to calculate premium.
(1) If a person’s health is excellent and the person is between 25 and 35 years of age and lives in a city and is a male then the premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2 lakhs.
(2) If a person satisfies all the above conditions except that the sex is female then the premium is Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakh.
(3) If a person’s health is poor and the person is between 25 and 35 years of age and lives in a village and is a male, then the premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000.
(4) In all other cases the person is not insured.
Write a program to output whether the person should be insured or not, his/her premium rate and maximum amount for which he/she can be insured.
Ans. insert
Code:
#include <stdio.h>
#include <conio.h>
void main()
{
int age;
char health[10], gen[6], loc[7];
printf("Health: \nAge: \nGender: \nLocation: \n");
scanf("%s%d%s%s",&health,&age,&gen,&loc);
printf("Health: %s \nAge: %d \nGender: %s \nLocation: %s \n",health,age,gen,loc);
if(age>=25 && age<=35)
{
if(health=="excellent")
{
if(loc=="city")
{
if(gen=="male")
{
printf("The premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2 lakhs");
}
else if(gen=="female")
{
printf("The premium is Rs. 3 per thousand and his policy amount cannot exceed Rs. 1 lakhs");
}
else
{
printf("The person is not insured");
}
}
else
{
printf("The person is not insured");
}
}
else if(health=="poor")
{
if(loc=="village")
{
if(gen=="male")
{
printf("The premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000");
}
else
{
printf("The person is not insured");
}
}
else
{
printf("The person is not insured");
}
}
else
{
printf("The person is not insured");
}
}
else
{
printf("The person is not insured");
}
getch();
}