Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write in c++ ASAP thx The goal of this task is to simulate an investment fund scenario using C++ classes and objects. Students will

Please write in c++ ASAP thx

The goal of this task is to simulate an investment fund scenario using C++ classes and objects. Students will implement a program that models the behavior of an investment fund, allowing users to buy and sell stocks, record investments from individual investors, and display relevant information about the fund's portfolio and investor contributions.

1. Global Constants and Stock Prices

  • Define global constants for the number of stocks (NUM_STOCKS) and trading days (TRADING_DAYS).
  • Create a 2D array stockPrices representing the close prices of 5 stocks over 22 trading days.

2. Human, Investor, and Fund Classes

  • Implement a Human class with basic attributes such as name and age.
  • Create an Investor class that inherits from Human. Investors can invest money into a fund.
  • Develop a Fund class with methods for buying and selling stocks, recording investments, and displaying fund information.

3. Fund Operations

  • Allow the Fund class to buy and sell stocks on specific days, adjusting stock weights and cash positions accordingly.
  • Implement methods to record investments from investors, display fundraising information, and showcase the fund's portfolio.

4. Investor Operations

  • Enable the Investor class to invest a specified amount of money into a fund, updating the investor's capital.
  • Display information about each investor, including their investments and remaining capital.

5. Simulation and Display

  • Create a simulation in the main function where investors invest in the fund, stocks are bought and sold, and the fund's portfolio is displayed.
  • Display relevant information at each step, such as investment details, fund portfolio, and the total value of the fund on the last trading day.

Additional Notes

  • Use appropriate member variables and encapsulation in the classes. Ensure error handling for insufficient funds or stocks during transactions.
  • The provided code contains placeholders for certain functionalities; students should complete the logic based on the task requirements.

int main () {

// Create investors

Investor investor_john("John Doe", 30, 15000.0);

Investor investor_alex("Alex Wong", 27, 7000.0);

// Create funds

Fund fund_g ("Global Growth Fund");

Fund fund_r("River Flow Hedge Fund");

cout < "Display initial investor information" < endl; investor_john.displayInvestorInfo(); investor_alex.displayInvestorInfo();

cout << endl;

cout << "Simulate investments" << endl; investor_john. invest (12000.0, fund_g); investor_alex. invest (5000.0, fund_r); investor_john. invest (3000.0, fund_r); investor_alex.invest (5000.0, fund_g);

cout << endl;

cout << "Display updated investor information" << endl; investor_john.displayInvestorInfo(); investor_alex.displayInvestorInfo();

cout << endl;

cout < "Simulate buying and selling stocks in the fund" < endl;

/ The fist stock is stock, the last stock is stock4.

fund_g.buyStocks (2, 10, 4000.0); // Buy $4000 worth of Stock 2 on Day

10

fund_g.sellStocks(2, 15, 3000.0); // Sell $3000 worth of Stock 2 on

Day 15

fund_r.buyStocks (2, 12, 2000.0); // Buy $2000 worth of Stock 2 on Day

12

fund_g.sellStocks(2, 19, 1000.0); // Sell $1000 worth of Stock 2 on

Day 19 cout << endl;

cout < "Display fund investments" << endl; fund_g.displayFundRaiseInfo); fund_r.displayFundRaiseInfo();

cout << endl;

cout << "Display fund final value" << endl;

double lastValue_fund_g = fund_g.getFundValueLastDay ();

double lastValue_fund_r = fund_r.getFundValueLastDay ();

cout << "The Global Growth Fund 's value at the last day is: " << lastValue_fund_g << endl;

cout < "The River Flow Hedge Fund 's value at the last day is: " lastValue_fund_r << endl;

return 0;

Sample

Display initial investor information

Investor Name: John Doe Age: 30 Current cash remained: 15000

Investor Name: Alex Wong Age: 27 Current cash remained: 7000

Simulate investments

John Doe invested $12000 in Global Growth Fund

Alex Wong invested $5000 in River Flow Hedge Fund John Doe invested $3000 in River Flow Hedge Fund

Capital is insufficient for the investment

Display updated investor information

Investor Name: John Doe Age: 30 invests Global Growth Fund for 12000 USD, invests River Flow Hedge Fund for 3000 USD, Current cash remained: 0

Investor Name: Alex Wong Age: 27 invests River Flow Hedge Fund for 5000

USD, Current cash remained: 2000

Simulate buying and selling stocks in the fund

Global Growth Fund Bought 52 shares of Stock 2 on Day 10 for $4000

Global Growth Fund Sold 38 shares of Stock 2 on Day 15 for $3000

River Flow Hedge Fund Bought 25 shares of Stock 2 on Day 12 for $2000

Global Growth Fund Sold 12 shares of Stock 2 on Day 19 for $1000

Display fund investments

In Fund Global Growth Fund:

Investor John Doe invests 12000USD

In Fund River Flow Hedge Fund:

Investor Alex Wong invests 5000USD

Investor John Doe invests 3000USD

Display fund final value

The Global Growth Fund 's value at the last day is: 12160.4

The River Flow Hedge Fund 's value at the last day is: 8005

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Heikki Topi, Jeffrey A Hoffer, Ramesh Venkataraman

13th Edition

0134773659, 978-0134773650

More Books

Students also viewed these Databases questions

Question

> Descri be how stories foster character devel opment.

Answered: 1 week ago