Question

In: Computer Science

To write a C++ program for following scenario and display requirements: Scenario-based Problem: AIG Insurance wants...

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. The use of struct to hold 3 or more of your variables as member variables.
  2. The use of functions to return all computed values.
  3. To write in a file (filename.txt) the output that you will display in the screen.
  • Don’t forget to:

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++.

Solutions

Expert Solution

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

}


Related Solutions

Write a C program that meets the following requirements. Uses a while loop to display the...
Write a C program that meets the following requirements. Uses a while loop to display the first 10 natural numbers (on one row, with a tab separating each number) Uses a while loop to find the sum of the second set of 10 natural numbers. Reads a user entry and displays all the natural numbers up to the user entry (on a column list with a new line separating each number). Finds and displays the sum of all natural numbers...
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 to display toy name
Write a C++ program to display toy name
Write a program that validates passwords based on the following requirements: • must be at least...
Write a program that validates passwords based on the following requirements: • must be at least 8 characters in length • must include at least 1 alphabet character • must include at least 1 number The program should implement the password checker using a function name validate_password, which takes two strings as input and returns one of the following: • 0 if the passwords match and fulfill all requirements • 1 if the passwords are not the same length •...
Write a program that validates passwords based on the following requirements: • must be at least...
Write a program that validates passwords based on the following requirements: • must be at least 8 characters in length • must include at least 1 alphabet character • must include at least 1 number The program should implement the password checker using a function name validate_password, which takes two strings as input and returns one of the following: • 0 if the passwords match and fulfill all requirements • 1 if the passwords are not the same length •...
Write a program that will calculate and display the cost of a gasoline purchase based on...
Write a program that will calculate and display the cost of a gasoline purchase based on the brand of gasoline, the octane rating and the amount purchased. Your program should first display a menu prompting the user for the brand of gasoline.  Next prompt the user for the amount of gasoline in liters. Finally, your program should calculate and display the cost of the gasoline purchase using the formula below. Cost of Discount Gasoline = ($2.49 - (100 - Octane Rating)...
C++ PLEASE Write a program to prompt the user to display the following menu: Guess-Number                       ...
C++ PLEASE Write a program to prompt the user to display the following menu: Guess-Number                        Concat-names             Quit If the user selects Guess-number, your program needs to call a user-defined function called int guess-number ( ). Use random number generator to generate a number between 1 – 100. Prompt the user to guess the generated number and print the following messages. Print the guessed number in main (): Guess a number: 76 96: Too large 10 Too small 70 Close...
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
Question 1: Write an AVR program to display text on a 2-line WH2002 LCD display based...
Question 1: Write an AVR program to display text on a 2-line WH2002 LCD display based on the HD44780 controller. Apply the following: The LCD instruction/data bus is connected to PORTD, and control bus is connected to PORTB (RS is connected to PB0, R/W to PB1, E to PB2). Use the #define command to name PORTD as Display_port. Use the #define command to name PORTB as Control_port. The displayed information is stored in the microcontroller Flash ROM (maximum size of...
Using c++, write a program that will display your name as a void function then will...
Using c++, write a program that will display your name as a void function then will perform the following by user-defined functions: a. to compute for the sum of two numbers (n1, n2) using function.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT