Saturday, 5 March 2022

11. The ABC Insurance Company Ltd. Offers the following three categories of car insurance policy to car owners: • Category A, here the basic premium is calculated as 2% of the car’s value. • Category B, here the basic premium is calculated as 3% of the car’s value. • Category C, here the basic premium is calculated as 5% of the car’s value.

#include<stdio.h>
#include<conio.h>

void main()
{
    float car;
    char category;
    clrscr();

    printf("ABC insuarance company ltd. offers:");
    printf("\n\ncategory A, here the basic premium is calculated as 2%c
            of the car's value",37);
    printf("\ncategory B, here the basic premium is calculated as 3%c     
            of the car's value",37);
    printf("\ncategory C, here the basic premium is calculated as 5%c
            of the car's value",37);

    printf("\n\nenter category: ");
    scanf("%c",&category);

    printf("\nenter car value: ");
    scanf("%f",&car);

    switch(category)
    {
        case 'A': car = car * 2 / 100;

                     printf("\npremium is: %0.2f",car);
                     break;

        case 'B': car = car * 3 / 100;

                     printf("\npremium is: %0.2f",car);
                     break;

        case 'C': car = car * 5 / 100;

                     printf("\npremium is: %0.2f",car);
                     break;

        default : printf("\nenter valid value");
    }

    getch();
}

/*  output:

category A, here the basic premium is calculated as 2107370f the car's value
category B, here the basic premium is calculated as 3107370f the car's value    
category C, here the basic premium is calculated as 5107370f the car's value    
                                                                               
enter category: A                                                              
                                                                               
enter car value: 100000                                                        
                                                                               
premium is: 2000.00

*/ 

No comments:

Post a Comment

python programs

1. sum of two number