Insurance Guide

 Insurance Guide

An Insurance company follows the following rules to calculate the premium, given the details of age,gender and area where the indivdual is living. 

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 print "The person cannot be insured". 

Write a program to calculate whether the person should be insured or not, his/her premium rate and maximum amount for which he/she can be insured. 

Business rules: 

1. The minimum and maximum age of a person to get insured are 25 and 35 respectively. Else it should print "Invalid age". 
2. Policy amount should not exceed Rs. 2 lakhs. If it exceeds, should display an appropriate message to the screen saying “Policy amount should not exceed Rs. 2 lakhs” 
3. You should enter P (Poor)/E (Excellent) as the value of health condition of the Insuree (The person   receiving insurance provided by the insurer).Else it should print "Invalid health condition". 
4. You should enter C (City)/ V (Village) as area. Else it should print “Invalid area”. 
5. Gender should be either M/F. Other than these should output in “Invalid gender”. 

Sample Input 1 
E M C 27 
Sample Output 1 
Successfully Insured.   
Premium Rate is Rs. 4 per 1000 
Maximum policy amount = Rs. 200000 

Sample Input 2 
E F C 32 
Sample Output 2 
Successfully Insured. 
Premium Rate is Rs. 3 per 1000 
Maximum policy amount = Rs. 100000 

Sample Input 3 
P M V 26 
Sample Output 3 
Successfully Insured. 
Premium Rate is Rs.6 per 1000 
Maximum policy amount = Rs. 10000 

Sample Input 4 
E F C 37 
Sample Output 4 
Invalid age 

The Method and parameters are: 
void calculatePremium(char health, char sex, char area, int age) 

Image result for c programming

Code:
Code
#include<stdio.h>
#include<conio.h>
int main()
{
char health,sex,area;
int age;

printf("Enter health condn(e/p),sex(m/f),area(c/v)&age\n");
scanf("%c %c %c %d",&health,&sex,&area,&age);

if(health=='e'&&sex=='m'&&area=='c'&&age>=25&&age<=35)
{
printf("\nInsured\n");
printf("\nPremium rate = Rs. 4 per 1,000\n");
printf("\nmaximum policy amount = Rs. 2,00,000");
}
else
if(health=='e'&&sex=='f'&&area=='c'&&age>=25&&age<=35)
{
printf("\nInsured");
printf("\nPremium Rate = Rs. 3 per 1000");
printf("\nMaximum policy amount = Rs. 1,00,000");
}
else
if(health=='p'&&sex=='m'&&area=='v'&&age>=25&&age<=35)
{
printf("\nInsured");
printf("\nPremium Rate = Rs. 6 per 1,000");
printf("\nMaximum policy amount = Rs. 10,000");
}
else
printf("\nYou cannot be insured\n");

printf ("\n\nPress any key to close.");

getch ();
return 0;

}

No comments: