Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ languge Write a program for an Insurance company that calculates a policy am

ID: 3832919 • Letter: C

Question

C++ languge

Write a program for an Insurance company that calculates a policy amount based on the type of policy a person is choosing. The monthly premium rates should be stored in an array as follows Health Insurance is $250.00. Auto Insurance is $125.00. and Life Insurance is $75.00. Write a module that asks the user for the policy type (1 = Health Insurance, 2 = Auto Insurance, 3 = Life, 4 = Health and Auto, 5 = Auto and Life, 6 = Health and Life, 7 = All three Your module should validate the data to make sure that they only choose values from 1 - 7. Should they choose an invalid amount, they should see an error message and be allowed to Once the user enters the policy type, the main() function should then use the array to determine their policy amount (without discounts). That policy amount and their choice will then be sent to another modulo that calculates both the discount amount and the total monthly premium based on their choice. If they choose two policy types, then give them a 10% discount on their monthly premium. If they choose all three policy types then give them a 20% discount on their monthly premium. Write a module that prints their individual price of their insurance, any discounts that apply and their final monthly premium payment. All of the modules will be called from main(). Once finished, ask the user if they would like to repeat the process for another policy quote.

Explanation / Answer

#include <iostream>
#include <stdio.h>
using namespace std;
void repeatProcess();
void calculatePremium(float, int);
int main()
{
int policyAmount[3]={250,125,75};
int policy;
char choice;
float premAmt;


do{
cout<<"select 1 for Health insurance"<<" ";
cout<<"select 2 for Auto insurance"<<" ";
cout<<"select 3 for life insurance"<<" ";
cout<<"select 4 for Health and Auto insurance"<<" ";
cout<<"select 5 for AUTO AND Life insurance"<<" ";
cout<<"select 6 forLife an Health insurance"<<" ";
cout<<"select 7 for All three insurances"<<" ";
cout<<"enter the policy you want to choose"<<" ";
cin>>policy;
if(policy==1){
premAmt=policyAmount[0];
  
calculatePremium(premAmt,policy);// CALLING MODULE TO CALCULATE PREMIUM

}
else if(policy==2){
premAmt=policyAmount[1];
calculatePremium(premAmt,policy);
}
else if(policy==3){
premAmt=policyAmount[2];
calculatePremium(premAmt,policy);
}
else if(policy==4){
cout<<"The individual price for Health insurance:"<<policyAmount[0];
cout<<"The individual price for auto insurance:"<<policyAmount[1];
  
premAmt=policyAmount[0]+policyAmount[1];
calculatePremium(premAmt,policy);
}
else if(policy==5){
cout<<"The individual price for auto insurance:"<<policyAmount[1]<<" ";
cout<<"The individual price for life insurance:"<<policyAmount[2]<<" ";
premAmt=policyAmount[1]+policyAmount[2];
calculatePremium(premAmt,policy);
}
else if(policy==6){
cout<<"The individual price for Health insurance:"<<policyAmount[0]<<" ";
cout<<"The individual price for life insurance:"<<policyAmount[2]<<" ";
premAmt=policyAmount[0]+policyAmount[2];
calculatePremium(premAmt,policy);
}
else if(policy==7){
cout<<"The individual price for Health insurance:"<<policyAmount[0]<<" ";
cout<<"The individual price for auto insurance:"<<policyAmount[1]<<" ";
cout<<"The individual price for life insurance:"<<policyAmount[2]<<" ";
premAmt=policyAmount[0]+policyAmount[1]+policyAmount[2];
calculatePremium(premAmt,policy);
}
else {
  
cout<<"enter valid policy number ";
  
}
cout<<"enter Y for process again and N for exit ";// ASK USER IF HE WANTS TO SELECT ANOTHER POLICY
cin>>choice;
  
}while(choice=='Y');
return 0;
}

void calculatePremium(float premium, int policyNo){
  
if(policyNo==1||policyNo==2||policyNo==3){
  
cout<< "The final price for insurance is :" <<premium<<" ";
  
  
  
}
if(policyNo==4||policyNo==5||policyNo==6){
  
  

premium=premium*0.9;// GIVING 10%DISCOUNT ON 2 INSURANCES
  
cout<< "you are getting 10% discount on total of monthly premium as you selected 2 insurances ";
cout<< "The final price for insurance is :" <<premium<<" ";
}
if(policyNo==7){
  
  

premium=premium*0.8;// GIVING 20%DISCOUNT ON 3 INSURANCES
  
cout<< "you are getting 20% discount on total of monthly premium as you selected 3 insurances";
cout<< "The final price for insurance is :" <<premium<<" ";
}
}
  

OUTPUT:

sh-4.2$ main                                                                                                                                                                    

select 1 for Health insurance                                                                                                                                                   

select 2 for   Auto insurance                                                                                                                                                   

select 3 for life insurance                                                                                                                                                     

select 4 for Health and Auto insurance                                                                                                                                          

select 5 for AUTO AND Life insurance                                                                                                                                            

select 6 forLife an  Health insurance                                                                                                                                           

select 7 for All three insurances                                                                                                                                               

enter the policy you want to choose                                                                                                                                             

6                                                                                                                                                                               

The individual price for Health insurance:250                                                                                                                                   

The individual price for life insurance:75                                                                                                                                      

you are getting 10% discount on  total of monthly premium as you selected 2 insurances                                                                                          

The final price for insurance is :292.5                                                                                                                                         

enter Y for process again and N for exit

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote