In: Computer Science
Write a C++ program to calculate the price of the annual insurance of a private vehicle according to the following table. Age of the person Model year of the car History of Accident Insurance price Less than 40 years Less than 2015 Yes 20 % more than price of last year No 15 % more than price of last year Later than 2015 Yes 12 % more than price of last year No 10 % more than price of last year More than 40 years Less than 2015 Yes 18 % more than price of last year No 13 % more than price of last year Later than 2015 Yes 12 % more than price of last year No 5 % more than price of last year Program should take the year of birth of the person, model year of the car, history of accident and the price for the last year from the user.

CODE: (Text File Also Included into End)


CODE: inc.cpp
#include 
using namespace std;
int main()
{
   cout << "*** Insurance Calculator ***\n";
   int yearOfBirth, modelYear, lastYearPrice,
accidentHistory, currentYear, incrementRate;
  
    // Taking Year Of Birth Input
    cout << "Enter Year Of Birth\n";
    cin >> yearOfBirth;
    // Taking Model YearInput
    cout << "Enter Model Year Of Car\n";
    cin >> modelYear;
    // Last Year Price
    cout << "Enter Last Year Insurance
Price\n";
    cin >> lastYearPrice;
    // Accident History (1 = Yes, 0 = No)
    cout << "If you have Accident History
Please Type 1 Otherwise 0\n";
    cin >> accidentHistory;
    //Program
    currentYear = 2019;
    int age = currentYear - yearOfBirth;
    if(age < 40){
       if (modelYear < 2015)
       {
          
if(accidentHistory == 1){
          
    incrementRate = 20;
           }else{
          
    incrementRate = 15;
           }
       }else{
          
if(accidentHistory == 1){
          
    incrementRate = 12;
           }else{
          
    incrementRate = 10;
           }
       }
    }else{
       if (modelYear < 2015)
       {
          
if(accidentHistory == 1){
          
    incrementRate = 18;
           }else{
          
    incrementRate = 13;
           }
       }else{
          
if(accidentHistory == 1){
          
    incrementRate = 12;
           }else{
          
    incrementRate = 5;
           }
       }
    }
cout << "Increment Rate: " << incrementRate;
    // Using Double Because incrementRate/100 is
in decimals
    double insurancePrice = (lastYearPrice * (1 +
((double)incrementRate/100)));
   cout << "\nAnnual Insurance: "
<<(int)insurancePrice;
  
return 0;
}