In: Computer Science
Automobile Insurance Program:
Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules:
-->I am solving this problem in C language.
->explanation of the code written in as comments in the programme.
C programme code:
#include<stdio.h>
int main() //main
{
int choose,choose2; //declaring variables
printf("1.Honda \t 2.Toyoto \t 3.Nissan\n"); //vehicle
menu
printf("Choose(1,2 or 3) Vehicle from above:");
//asking input from user
scanf("%d",&choose); //taking input from
user
if(choose==1) //condition 1
{
printf("\n\n1.All Wheel \t 2.Two
Wheel\n"); //vehicle wheel type menu
printf("Enter your Honda Wheel
type:"); //asking input from user
scanf("%d",&choose2); //taking
input from user
if(choose2==1) //condition 1
{
printf("\nInsurance fee to pay your Honda vehicle is= $450");
//display the insurance
}
else if(choose2==2) //condition
2
{
printf("\nInsurance fee to pay your Honda vehicle is= $350");
//display the insurance
}
else //false condition
{
printf("\nPlease
choose respective vehicle wheel type only i.e 1 or 2"); //error
message
}
}
else if(choose==2) //condition 2
{
printf("\n\n1.All Wheel \t 2.Two
Wheel\n");
printf("Enter your Toyota Wheel
type:");
scanf("%d",&choose2);
if(choose2==1)
{
printf("\nInsurance fee to pay your Toyota vehicle is=
$300");
}
else if(choose2==2)
{
printf("\nInsurance fee to pay your Toyota vehicle is=
$250");
}
else
{
printf("\nPlease
choose respective vehicle wheel type only i.e 1 or 2");
}
}
else if(choose==3) //condition 3
{
printf("\n\n1.All Wheel \t 2.Two
Wheel\n");
printf("Enter your Nissan Wheel
type:");
scanf("%d",&choose2);
if(choose2==1)
{
printf("\nInsurance fee to pay your Nissan vehicle is=
$200");
}
else if(choose2==2)
{
printf("\nInsurance fee to pay your Nissan vehicle is=
$280");
}
else
{
printf("\nPlease
choose respective vehicle type only i.e 1 or 2");
}
}
else //false condition
{
printf("\nPlease choose respective
vehicle type only i.e 1 or 2 or 3");
}
return 0;
}
Image reference/Output: