Question

In: Computer Science

Your task is to write a little utility program to assist a local insurance agency on...

Your task is to write a little utility program to assist a local insurance agency on calculating monthly cost of car insurance based on personal information and driving history of the individual requesting it.

These are the requirements for the program:

Req 1: The base monthly cost of insuring a car is $50.00 -- this is the starting cost, we will add to this cost as we collect more information (see the rest of the requirements)

Req 2: Your program should get the age of the driver from the user.

If the driver is under the age of 25, the monthly premium goes up $100;

otherwise, If the driver is under the age of 35, the monthly premium goes up $20.

For example, for a 23 year old driver, you should add $100 to the base premium. For a 28 year old driver, you should add only $20 to the base premium. Any driver over the age of 35, does not get any additional premium due to age.

Req 3: Program should get the number of accidents in the last 5 years from the user.

Up to one accident is forgiven under accident forgiveness policy.

If the number of accidents is less than 3, then you add $40 per accident.

If the number of accidents is more than or equal to 3, you add $60 per accident to the monthly premium.

If driver had more than 4 accidents in the past 5 years, we cannot provide insurance (let the user know with a message).

Number of Accidents: Accident Surcharge

1 Accident None = Accident Forgiveness, no additional charge

2 Accidents $40 per accident = $80 additional charge

3 Accidents $60 per accident = $180 additional charge

4 Accidents $60 per accident = $240 additional charge

5 Accidents Can not insure

Use the following test cases to make sure that your program is functioning properly.

Based on the above 3 requirements, compute and output the monthly premium for the driver.

Test Case 1: 24 years old driver with no accident should output $150.00.

Test Case 2: 24 years old driver with 3 accidents should output $330.00.

Test Case 3: 26 years old driver with no accidents should output $70.00.

Test Case 4: 50 years old driver with 2 accidents should output $130.00.

Submit the cpp file for grading.

Solutions

Expert Solution

Program:

#include <iostream>
using namespace std;
int main() {
int baseCost=50;//basecost
int age;//to hold age of driver
int accidents;//to hold no of accidents
int totalCost=0;//to hold total cost of insurance
cout<<"Enter the age of driver";//asking user to enter age reading into age
cin>>age;
cout<<"Enter the no of accidents made by driver in last 5 years";//asking uset to enter no of accidents and storing in accidents
cin>>accidents;
if(accidents>4)//checking if no of accidents greater than 4 then printing message and returning
{
cout<<"Accidents Cannot Insure ";
return 0;
}
if(age<25)//if age is less than 25 theh adding 100 to base cost
totalCost+=baseCost+100;
else if(age>=25 && age <35)//if age is betwwen 25 and 35 then adding 20 o base cost
totalCost+=baseCost+20;
else
totalCost+=baseCost;
//calculating accidents charge amount
if(accidents<3)
totalCost+=40*accidents;
else if(accidents>=3)
totalCost+=60*accidents;
  
cout<<"Total Insurance Amount: $"<<totalCost;
  
}

Output:


Related Solutions

Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
CODE IN PYTHON: Your task is to write a simple program that would allow a user...
CODE IN PYTHON: Your task is to write a simple program that would allow a user to compute the cost of a road trip with a car. User will enter the total distance to be traveled in miles along with the miles per gallon (MPG) information of the car he drives and the per gallon cost of gas. Using these 3 pieces of information you can compute the gas cost of the trip. User will also enter the number of...
Your Task: Write a calculator Program with following functions (lack of function will result in a...
Your Task: Write a calculator Program with following functions (lack of function will result in a grade of zero). Your program must have the following menu and depending on the users choice, your program should be calling the pertaining function to display the result for the user. 1 - Add 2 - Subtract 3 - Multiply 4 - Divide 5 - Raise X to the power Y 6 - Finds if a number is even or odd 0 - Quit...
Your Task: Write a calculator Program with following functions (lack of function will result in a...
Your Task: Write a calculator Program with following functions (lack of function will result in a grade of zero). Your program must have the following menu and depending on the users choice, your program should be calling the pertaining function to display the result for the user. 1 - Add 2 - Subtract 3 - Multiply 4 - Divide 5 - Raise X to the power Y 6 - Finds if a number is even or odd 0 - Quit...
Your task is to write a C program which performs encryption and decryption of a message...
Your task is to write a C program which performs encryption and decryption of a message using the substitution cipher algorithm. Write a C program which performs encryption and decryption using the substitution cipher algorithm. Your program must be fully automated (ie: it does not take any interactive user input) and either encrypt or decrypt depending on the files which exist in the program’s directory. If message.txt exists your program should read that file, encrypt the contents, and write the...
(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...
Write a program fragment (not a complete program) which will perform the following task: The int...
Write a program fragment (not a complete program) which will perform the following task: The int variable m currently contains the number of minutes a basketball player played in their last game. Use an IF statement(s) to print out an appropriate message based on the following: If m is from 35 to 48, print the message "very tired" If m is from 10 to 34, print the message "little tired" If m is from 1 to 9, print the message...
You are appointed to a task force in your health agency that has been asked to...
You are appointed to a task force in your health agency that has been asked to make recommendations about personal health electronic records for your patient population. Your team has been asked to evaluate the following: What level of access should patients to the EHR in use by your healthcare organization (should patients have access to everything in their record or just specific parts?) What are the opportunities to promote patient engagement and better care coordination through the implementation of...
I got a little problem when i was trying to write a program that takes a...
I got a little problem when i was trying to write a program that takes a hexadecimal number and convert it to a binary number. It just don't give me the right answer. Here's my code: #include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> int main(int argc, char *argv[]) { unsigned long int i; i=0xffff; char buffer[65]; sprintf(buffer, "%lud", i); long int x = 0; while (buffer[x]) {    switch (buffer[x]) { case '0': printf("0000"); break; case '1': printf("0001"); break;...
For your job as the business reporter for a local newspaper, you are given the task...
For your job as the business reporter for a local newspaper, you are given the task of putting together a series of articles that explains the power of the time value of money to your readers. Your editor would like you to address several specific questions in addition to demonstrating for the readership the use of the time value of money techniques by applying them to several problems. What should be your response to the following memorandum from your editor?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT