In: Computer Science
To write a C++ program for following scenario and display requirements:
Scenario-based Problem:
AIG Insurance wants to create an insurance management system for their clients. The insurance management system will compute the required payments from the clients. The commission of the agent shall also be computed which depends on the amount of insurance type.
Insurance Type |
Amount of Insurance type |
Agent Commission |
Life |
2500 |
12.5% of amount |
Health |
1500 |
10.5% of amount |
Other inputs |
0 |
0 |
Computation of monthly payments and equity value depends on the number of months to pay
Insurance Type |
Number of months to pay |
Equity Value |
Life |
1 – 12 |
7% of amount |
13 – 24 |
9% of amount |
|
More than 24 |
11% of amount |
|
Health |
1 – 12 |
8% of amount |
13 – 24 |
10% of amount |
|
More than 24 |
12% of amount |
|
Other inputs |
Any number |
0 |
The program will begin by inputting the number of policies. The number of policies will be used as basis for the number of times user will input the following: client’s name, mobile number, insurance type as well as the number of months to pay. The agent commission and the equity value is computed based on the two tables. The monthly due is computed as insurance type amount minus the reservation amount divided by the number of months to pay. The reservation amount is computed as 2% of the amount of insurance type. The program should display in a summary or tabular format the following information: client’s mobile number, client’s name, the insurance type, number of months to pay, monthly due, agent commission, and reservation amount. All the necessary values should be stored in a pointer array. (client’s mobile number, client’s name, the insurance type, number of months to pay, monthly due, agent commission, and reservation amount).
At the end of the report, the program should also display the following:
A. the number of times A life insurance type was
bought
b. The lowest number of months entered by the user
c. The total of all reservation fees
d. The agent commission sorted from lowest to highest (ascending)
You are also requested to consider the following requirements:
1. Construct programs using pre-processors, static variables, and external variables
2. Develop program using recursive and library functions (math, string and time).
3. Work with pointers including void,
array and function pointers.
4. Use derived data types like structures and unions.
5. Perform file handling
operations.
6. Use Dynamic Memory Management concepts.
7. Use type qualifiers and macros in
programs.
8. Create templates in C++.
#include <iostream>
#include <string>
#include <algorithm>
#include<bits/stdc++.h>
using namespace std;
struct detail {
string first_name;
string last_name;
string number;
string insurance_type;
float months;
float amount;
float commission;
float equity;
float monthly_due;
float reservation_amount;
};
float due(float amount,float months)
{
float res_amt=amount*2/100;
return (amount-res_amt)/months;
}
float commission(float amount,string type)
{
if(type=="life"){
amount=amount/100;
return (amount*12.5);
}
else if(type=="health")
{
amount=amount/100;
return (amount*10.5);
}
}
float equity(float months,float amount,string type)
{
if (type=="life")
{
if(months<=12 && months>=1)
{
return (amount*7/100);
}
else if(months>12 && months<=24)
{
return (amount*9/100);
}
else if(months>=25)
{
return (amount*11/100);
}
}
else if(type=="health")
{
if(months<=12)
{
return (amount*8/100);
}
else if(months>12 && months<24)
{
return (amount*10/100);
}
else if(months>=25)
{
return (amount*12/100);
}
}
else
{
return 0;
}
}
int main()
{
int life=0;
int health=0;
int lowest_month=1000000;
int total_res_fee=0;
int n;
cin >>n;
float agent_commission[n];
struct detail client[n];
int i;
for(i=0;i<n;i++)
{
cout << "Please enter your first name: \n";
cin>> client[i].first_name;
cout << "Please enter your last name: \n";
cin>>client[i].last_name;
cout << "Please enter your mobile number: \n";
cin>>client[i].number;
cout << "Please enter your insurance type: \n";
cin>> client[i].insurance_type;
transform(client[i].insurance_type.begin(),
client[i].insurance_type.end(), client[i].insurance_type.begin(),
::tolower);
if(client[i].insurance_type=="life")
{
client[i].amount=2500;
life=life+1;
}
else if(client[i].insurance_type=="health")
{
client[i].amount=1500;
health=health+1;
}
else{
client[i].amount=0;
}
agent_commission[i]=commission(client[i].amount,client[i].insurance_type);
cout << "Please enter total number of months: \n";
cin >>client[i].months;
if(lowest_month>client[i].months)
{
lowest_month=client[i].months;
}
total_res_fee=total_res_fee+(2*client[i].amount/100);
}
freopen( "filename.txt", "w", stdout );
for(i=0;i<n;i++)
{
cout<<"Client"<<i<<"-____------------------------"<<endl;
cout<<" CLIENT NAME "<<client[i].first_name<<"
"<<client[i].last_name<<endl;
cout<<"CLIENT MOBILE NUMBER
"<<client[i].number<<endl;
cout<<"INSURANCE TYPE
"<<client[i].insurance_type<<endl;
cout<<"TOTAL MONTHS
"<<client[i].months<<endl;
cout<<"AMOUNT OF INSURANCE
"<<client[i].amount<<endl;
client[i].commission=commission(client[i].amount,client[i].insurance_type);
cout<<"AGENT COMMSION
"<<client[i].commission<<endl;
client[i].equity=equity(client[i].months,client[i].amount,client[i].insurance_type);
cout<<"EQUITY VALUE
"<<client[i].equity<<endl;
client[i].monthly_due=due(client[i].amount,client[i].months);
cout<< "MONTHLY DUE
"<<client[i].monthly_due<<endl;
cout<< "RESERVATION AMOUNT
"<<client[i].amount*2/100<<endl;
}
cout<< "Total number of time LIFE insurance type is
selected "<<life<<endl;
cout<< "Total number of time HEALTH insurance type is
selected "<<health<<endl;
cout<< "Lowest number of months are
"<<lowest_month<<endl;
cout<< "total of all reservation fees
"<<total_res_fee<<endl;
sort(agent_commission, agent_commission+n,
std::greater<float>());
for(i=n-1;i>=0;i++)
{
cout<<agent_commission[i]<<" ";
}
return 0;
}