Question

In: Computer Science

Write a C++ program to calculate the price of the annual insurance of a private vehicle according to the following table.

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.

Solutions

Expert Solution

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;
}


Related Solutions

Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules:
C++ ProgrammAutomobile Insurance Program:Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules:A Honda that is All Wheel Drive costs $450.A Honda that is two wheels drive costs $350.A Toyota that is All Wheel Drive costs $300.A Toyota that is Two Wheel Drive costs $250.A Nissan that is All Wheel Drive costs $200.A Nissan that is Two Wheel Drive costs $280Any other type of vehicle generates an error message. The program should...
Write a C++ program that prints the insurance fee to pay for apet according to...
Write a C++ program that prints the insurance fee to pay for a pet according to the following rules:(NOTE:You must use a switch statement to determine pet fee.)A dog that has been neutered costs $50.A dog that has not been neutered costs $80.A cat that has been spayedcosts $40.A cat that has not been spayedcosts $60.A bird or reptile costs nothing.Any other animal generates an error message.The program should prompt the user for the appropriate information: a character code for...
C program help 1. Write a program to compute the Mileage given by a vehicle. Mileage...
C program help 1. Write a program to compute the Mileage given by a vehicle. Mileage = (new_odometer – old_odometer)/(gallons_gas) // illustrating how ‘for’ loop works. 2. How to initialize an array of size 5 using an initializer list and to compute it’s sum How to initialize an array of size 5 with even numbers starting from 2 using ‘for’ loop and to compute it’s sum 3. Program to compute the car insurance premium for a person based on their...
IN C++: Write a program to display the following table. MUST use for-loop Enter the table...
IN C++: Write a program to display the following table. MUST use for-loop Enter the table size: 10 N N^2 Square root of N --------------------------------------------- 1 1 1.00 2 4 1.41 3 9 1.73 ….. 10 100 3.16
Automobile Insurance Program: Writes a program that prints the insurance fee to pay for a Vehicle...
Automobile Insurance Program: Writes a program that prints the insurance fee to pay for a Vehicle according to the following rules: A Honda that is All Wheel Drive costs $450. A Honda that is two wheels drive costs $350. A Toyota that is All Wheel Drive costs $300. A Toyota that is Two Wheel Drive costs $250. A Nissan that is All Wheel Drive costs $200. A Nissan that is Two Wheel Drive costs $280.
Write a program that prints the insurance fee to pay for a pet according to the...
Write a program that prints the insurance fee to pay for a pet according to the following rules:(NOTE:You must use a switch statement to determine pet fee.)A dog that has been neutered costs $50.A dog that has not been neutered costs $80.A cat that has been spayedcosts $40.A cat that has not been spayedcosts $60.A bird or reptile costs nothing.Any other animal generates an error message.The program should prompt the user for the appropriate information: a character code for the...
Program Requirements: Write a C++ program according to the following requirements: 1.   Open the data file...
Program Requirements: Write a C++ program according to the following requirements: 1.   Open the data file Electricity.txt and read each column into an array (8 arrays total). 2.   Also create 2 arrays for the following: Total Fossil Fuel Energy (sum of all fossil fuels) Total Renewable Energy (sum of all renewable sources) Electricity.txt: Net generation United States all sectors monthly https://www.eia.gov/electricity/data/browser/ Source: U.S. Energy Information Administration All values in thousands of megawatthours Year   all fuels   coal       natural gas   nuclear  ...
Write a C++ program for the following problem: Calculate and print the area and volume of...
Write a C++ program for the following problem: Calculate and print the area and volume of a cone inside a While  loop that goes from 1 to 20 with a step of .5. (the step is 1/2 or Point 5, so you go 10, 10.5,11, 11.5) Note: Your loop variable will need to be a double data type Use two decimal places on all numbers that are double data type. This will be a table with 3 columns. Don't worry about...
(Write a program in C++) A local instructor wants you to write a program to calculate...
(Write a program in C++) A local instructor wants you to write a program to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60...
(C++) Write a program that prints a table in the following format given a "x" read...
(C++) Write a program that prints a table in the following format given a "x" read from the keyboard. For example, if x is 4, it prints out 0 0 1 1 2 4 3 9 4 16 To avoid mismatch, put 8 white spaces between two numbers.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT