In: Computer Science
Write a program to determine the cost of an automobile insurance premium, based on the driver's age and the number of accidents that the driver has had.
| 
 No. of accidents  | 
 ►  | 
 Accident Surcharge  | 
| 
 1  | 
 ►  | 
 25  | 
| 
 2  | 
 ►  | 
 25  | 
| 
 3  | 
 ►  | 
 75  | 
| 
 4  | 
 ►  | 
 75  | 
| 
 5  | 
 ►  | 
 100  | 
| 
 6 or +  | 
 ►  | 
 No assurance  | 
// C++ program to determine the cost of an automobile insurance
premium, based on the driver's age and the number of accidents that
the driver has had.
#include <iostream>
using namespace std;
int main() {
   int age, accidents;
   double insurance_charge = 500; // base charge
   // input of age
   cout<<"Enter the driver's age : ";
   cin>>age;
   // input of number of accidents
   cout<<"Enter the number of accidents the driver
has had : ";
   cin>>accidents;
   // if age < 25, add an additional surface of
100
   if(age < 25)
       insurance_charge += 100;
   // add the accident surcharge based on number of
accidents
   if(accidents == 1 || accidents == 2)
       insurance_charge += 25;
   else if(accidents == 3 || accidents == 4)
       insurance_charge += 75;
   else if(accidents == 5)
       insurance_charge += 100;
   // display the total insurance premium
   cout<<"Automobile Insurance premium :
$"<<insurance_charge<<endl;
   return 0;
}
//end of program
Output:

