Thursday 25 July 2013

Chapter 2 solutions problem [F][c]

Question-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.
Solution- Honestly speaking ,these type of questions are really boring.  Here is the solution.

#include<stdio.h>
int main()
{
int health,age,gender,residence;
printf("Enter your info. Health(Excellent=1,poor=0),age(25-35=1 ,else=0),gender(Male=1,female=0),residense info.(Rural=1,urban=0)\n");
scanf("%d%d%d%d",&health,&age,&gender,&residence);
if(health==1&&age==1&&gender==1&&residence==0)
printf(" premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2 lakhs\n");
else if (health==1&&age==1&&gender==0&&residence==0)
printf(" premium is Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakh\n");
else if(health==1&&age==1&&gender==0&&residence==1)
printf("premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000\n");
else
printf("Person can not be insured\n");
return 0;
}
/* We can write all condition together using || but it would difficult to read so i prefer this way */

2 comments:

  1. An Insurance company follows following rules to calculate premium.

    If a person’s health is excellent and the person is between 25 and 35 years (including both) 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.
    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.
    If a person’s health is poor and the person is between 25 and 35 years (including both) 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.
    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.

    Input Format

    E
    26
    C
    M
    5000

    where:
    First line is health condition (E- Excellent, P- Poor) Second line is Age in integer Third line is where he lives (C- city, V-village) Fourth line is gender (M- male, F-female) Fifth line is amount in double

    Constraints

    If user enters value which is not mentioned in question. Program should print "Input unspecified."

    Output Format

    Output for all categories should be one of following: 1. Policy amount exceed the limit. 2. Insurance amount. 3. You can not be insured. 4. Input unspecified.

    ReplyDelete
  2. plzzzz replyyyyyyyyyyyy this question any one

    ReplyDelete