Need help starting program

I need some assistance getting started with my project. I have most of the BankAccount class written, I just need some assistance with the portfolio portion. Any guidance to get me moving with this project would be beneficial, my professor is less than willing and directs us to read the book that does not help.

Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
 // Portfolio - Chapter 8
// Your name
// Project #
	
#include<iostream>
#include <stdio.h>
using namespace std;

class BankAccount
{
   private:
      int acctNum;
      double balance;
      double annualRate;
   public:
      BankAccount(int, double = 0.0, double = 0.0);
      void enterAccountData();
      void computeInterest(int);
      void displayAccount();
      double getBal();
};
BankAccount::BankAccount(int acct, double bal, double rate)
{
   // provide definition for this constructor
}
void BankAccount::enterAccountData()
{
    //provide definition for this method
}
void BankAccount::computeInterest(int years)
{
     //provide definition for this method
}
void BankAccount::displayAccount()
{
     //provide definition
}
double BankAccount::getBal()
{
     //provide definition
}
class Portfolio
{
   private:
     int clientNum;
     BankAccount checking;
     BankAccount savings;
     double stockMarketVal;
     double realEstateVal;
     void balancePortfolio();
  public:
     Portfolio(int, int, double, int, double, double, double, double);
     void display();
};
Portfolio::Portfolio(int client, int cNum, double cBal, int sNum,
	double sBal, double sRate, double stockVal,
	double realVal) : checking(cNum, cBal), savings(sNum, sBal, sRate)
{
    //provide definition
}
void Portfolio::balancePortfolio()
{
   //provide definition
}
void Portfolio::display()
{
   //provide definition
}
int main()
{
   	BankAccount ba1(123456), ba2(1234), ba3(2345, 2345.67), ba4(3456, 4567.89, 0.025);
	//provide code to display account information
	Portfolio p(/*you need to put the arguments here*/);
	//provide the remaining code here

}


This is the instructions that were provided to me. I was told to make this into one single .cpp file, rather than breaking it up into multiple.

You have been developing a BankAccount class for Parkville Bank that contains several
fields and functions. In previous chapters, you declared the interest rate to be static and
constant; remove those modifiers as well as the definition of the interest rate as 0.03.
Add a constructor to the class that accepts arguments for the account number, balance, and
interest rate. The account number is required, but both the balance and interest rate default
to 0 if no argument is supplied to the constructor. If the account number is not between 1000
and 9999 inclusive, force it to zero.
Modify the display function, if necessary, so that all BankAccountfields are displayed.
Write a main()function that declares several BankAccountobjects and confirm that the class
works correctly.
Save the file as BankAccount.cpp.
b. Parkville Investment Consulting keeps track of clients’ asset portfolios. Create a class named
Portfoliothat contains a client number and two BankAccountobjects—one for checking
and one for savings. Include two other double fields for stock market holdings total value
and real estate holdings total value. The Portfolioconstructor requires checking account
data (account number and balance), savings account data (account number, balance, and
interest rate), and the value of stock market and real estate holdings. The constructor calls
a function named balancePortfolio()that determines the relative percentage of the client’s holdings in each of the four investment types. If any investment type’s value is more
than 40% of the client’s total holdings, an appropriate message displays warning that the
client’s portfolio might be out of balance. Also create a display function for the Portfolio
class to display all the details. Add any additional functions you need to the classes.
Write a main()function that continues to prompt a user for Portfoliodata until a negative
value is entered for the client account number. Create each Portfolioobject and display its
values, including the possible out-of-balance warning message.
Save the file as Portfolio.cpp.
Last edited on
where exactly do you need help ?
I mainly need help getting the Portfolio class started:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class Portfolio
{
   private:
     int clientNum;
     BankAccount checking;
     BankAccount savings;
     double stockMarketVal;
     double realEstateVal;
     void balancePortfolio();
  public:
     Portfolio(int, int, double, int, double, double, double, double);
     void display();
};
Portfolio::Portfolio(int client, int cNum, double cBal, int sNum,
	double sBal, double sRate, double stockVal,
	double realVal) : checking(cNum, cBal), savings(sNum, sBal, sRate)
{
    //provide definition
}



This is what I have done for the BankAccount class.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class BankAccount
{
   private:
      int acctNum;
      double balance;
      double annualRate;
   public:
      BankAccount(int, double = 0.0, double = 0.0);
      void enterAccountData();
      void computeInterest(int);
      void displayAccount();
      double getBal();
};
BankAccount::BankAccount(int acct, double bal, double rate)
{
   acctNum = acct;
   if (acctNum < 1000 || acctNum > 9999 )
	{
		acctNum = 0; 
	}
	
   balance = bal;
   annualRate = rate;
  // BankAccount (acctNum, balance, annualRate);
}
void BankAccount::enterAccountData()
{
	
}

void BankAccount::computeInterest(int years)
{
	int count = 0;
	double balanceint = balance;
	 while (count < years)
    {
	balanceint = (balanceint * annualRate) + balanceint;
	count++;
	cout << "After " << count << " year(s), your account balance will be $" << balanceint << endl;
	 }
}
void BankAccount::displayAccount()
{
	cout << endl;
	cout << "The principle amount in account #" << acctNum << " is: $ " << balance << endl;
	cout << " with an intrest rate of: " << annualRate << endl;
	//provide definition
}
double BankAccount::getBal()
{
     return balance;
}
The Portfolioconstructor requires checking account
data (account number and balance), savings account data (account number, balance, and
interest rate), and the value of stock market and real estate holdings.


The Portfolio constructor requires checking account data (account number and balance)

I'm not sure how you will check that unless you pass a BankAccout object as a parameter:
1
2
3
4
5
6
7
8
9
10
11
12
Portfolio::Portfolio ( const BankAccount& temp, other_parameters )
{
    /* access the members by
    temp.acctNum
    temp.balance
    temp.savings
    etc... */
    // Call balance portfolio
    balancePortfolio( temp.acctNUm, bla, bla );
    
    /* Other */
}


I'm not really sure if this is what you mean
Topic archived. No new replies allowed.