Some insurance companies offer discounts on car insurance premiums depending on the number of years the driver has had a driver's licence and the number of claims the driver has made in the last five years. In this program, the user inputs (as integers) •years the number of years the driver has had a driver's license •claims the number of insurance claims made in the last five years The (integer) percentage of the "standard premium"that will be charged is initially calculated as follows: •if years< 5 then percentage = 100 –10 * years + 20 * claims •otherwise ("else") percentage = 50 + 20 * claims The percentage calculated in this way is then further adjusted as follows: •if percentage> 150 then insurance is refused •otherwise,if the percentage is between 100% and 150% then set percentage = 100 •(otherwise,the percentage isn't adjusted)
cout << "enter years licenced: " << endl;
cin >> years;
cout << "enter number of claims: " << endl;
cin >> claims;
if (years < 5)
{
percentage = 100 - (10 * years) + (20 * claims);
cout << "percentage from 0 to 5:" << percentage << endl;
}
else (years > 5);
{
percentage = 50 + (20 * claims);
cout << "percentage higher than 5:" << percentage << endl;
}
if (percentage > 150)
{
cout << "insurance is refused." << percentage << endl;
}
else if (100 <= percentage <= 150)
{
cout << "percentage = 100." << endl;
}
else;
{
cout << "insurance is refused." << endl;
}
return 0;