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 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.
#include <conio.h>
void main ( )
{
int age, pr, pol;
char hel, resi, sex;
clrscr ( );
printf ("\n\n\n\n\t\t\t Enter the values of \n\n");
printf ("\n\n\n\t\t Sex ( M/F ).......................:"); scanf ("%c", &sex);
fflush(stdin); /* To clear input buffer */
printf ("\n\n\t\t Health excellent/poor ( E/P ).......:"); scanf ("%c", &hel);
fflush(stdin);
printf ("\n\n\t\t Resident of city/village ( C/V )....:"); scanf ("%c", &resi);
fflush(stdin);
printf ("\n\n\t\t Age.................................:"); scanf ("%d", &age);
if (( sex == 'M' || sex == 'm' ) && ( hel == 'E' || hel == 'e' )
&& ( resi == 'C' || resi == 'c' ) && age >= 25 && age <= 35)
/* These conditions will work even if lowercase letters are entered */
{
printf ("\n\n\n\n\t\t The person is insured");
printf ("\n\n\t\t Premium = Rs. 4 per thousand");
printf ("\n\n\t\t Maximum insurance amount = Rs. 2 lakhs");
printf ("\n\n\n\n\n Press any key to exit");
getch ( );
exit ( ); /* Terminates Program execution */
}
if (( sex == 'F' || sex == 'f' ) && ( hel == 'E' || hel == 'e' )
&& ( resi == 'C' || resi == 'c' ) && age >= 25 && age <= 35)
/* These conditions will work even if lowercase letters are entered */
{
printf ("\n\n\n\n\t\t The person is insured");
printf ("\n\n\t\t Premium = Rs. 3 per thousand");
printf ("\n\n\t\t Maximum insurance amount = Rs. 1 lakhs");
printf("\n\n\n\n\n Press any key to exit");
getch ( );
exit ( ); /* Terminates Program execution */
}
if (( sex == 'M' || sex == 'm' ) && ( hel == 'P' || hel == 'p' )
&& ( resi == 'V' || resi == 'v' ) && age >= 25 && age <= 35)
/* These conditions will work even if lowercase letters are entered */
{
printf ("\n\n\n\n\t\t The person is insured");
printf ("\n\n\t\t Premium = Rs. 6 per thousand");
printf ("\n\n\t\t Maximum insurance amount = Rs. 10,000");
printf ("\n\n\n\n\n Press any key to exit");
getch ( );
exit( ); /* Terminates Program execution */
}
printf ("\n\n\n\n\t\t The person is not insured");
printf("\n\n\n\n\n Press any key to exit");
getch ( );
}
No comments:
Post a Comment