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

// Portfolio - Chapter 8 #include<iostream> using namespace std; class BankAccou

ID: 3542880 • Letter: #

Question

 // Portfolio - Chapter 8          #include<iostream> using namespace std;  class BankAccount {    private:       int acctNum;       double acctBal;           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 } void BankAccount::enterAccountData() {     int account;         double balance;         cout<<"Please enter the account number :";         cin>>account;         cout<<endl;         while(account< 1000 || account > 9999) {         cout<<"Error: Invalid account number,please try again. :"<<endl;         cin>>account; } //Allows user to enter a balance that cannot benegative         cout<<"Please enter the balance for "<<account << " : ";         cin>>balance;         cout << endl;         while(balance < 0) {         cout<<"Error: Invalid balance, cannot have a negative balance, please check and try again"<<endl;         cin>>balance; }         acctNum = account;                 acctBal = balance; } void BankAccount::computeInterest(int years) {         for(int i=0; i<years; i++); {         int interest = static_cast<int> (acctBal*0.03);         acctBal = acctBal + interest;         displayAccount(); } } void BankAccount::displayAccount() {         cout << "Account #" << acctNum << " ";         cout << "Account Balance :" << acctBal << endl; } double BankAccount::getBal() {      return acctBal; } 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() {    //provide definition } 
 
 
 This is my program right now and the question is parkville Investment Consulting keeps track of clients

Explanation / Answer

please rate - thanks


any questions ask

I corected your BankAccount class--you had an extra Balance, and used it instead of acctBal in the constructor

#include<iostream>
using namespace std;

class BankAccount
{
   private:
      int acctNum;
      double acctBal;
      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;
acctBal=bal;
annualRate=rate;
}
void BankAccount::enterAccountData()
{
    int account;
        double balance;
        cout<<"Please enter the account number :";
        cin>>account;
        cout<<endl;
        while(account< 1000 || account > 9999)
{
        cout<<"Error: Invalid account number,please try again. :"<<endl;
        cin>>account;
}
//Allows user to enter a balance that cannot benegative
        cout<<"Please enter the balance for "<<account << " : ";
        cin>>balance;
        cout << endl;
        while(balance < 0)
{
        cout<<"Error: Invalid balance, cannot have a negative balance, please check and try again"<<endl;
        cin>>balance;
}
        acctNum = account;
                acctBal = balance;
}
void BankAccount::computeInterest(int years)
{
        for(int i=0; i<years; i++);
{
        int interest = static_cast<int> (acctBal*0.03);
        acctBal = acctBal + interest;
        displayAccount();
}
}
void BankAccount::displayAccount()
{
        cout << "Account #" << acctNum << " ";
        cout << "Account Balance :" << acctBal << endl;
}
double BankAccount::getBal()
{
     return acctBal;
}
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,sNum)
{clientNum=client;
stockMarketVal=stockVal;
realEstateVal=realVal;
//provide definition
}
void Portfolio::balancePortfolio()
{double total;
bool warning=false;
total=checking.getBal()+savings.getBal()+stockMarketVal+realEstateVal;
if(checking.getBal()/total>.4)
     warning=true;
if(savings.getBal()/total>.4)
     warning=true;
if(stockMarketVal/total>.4)
         warning=true;
if(realEstateVal/total>.4)
     warning=true;
if(warning)
    cout<<"WARNING-your portfolio might be out of balance";
//provide definition
}
void Portfolio::display()
{cout<<"client "<<clientNum<<endl;
checking.displayAccount();
savings.displayAccount();
cout<<"Stock Market Value: $"<<stockMarketVal<<endl;
cout<<"Real Estate Value: $"<<realEstateVal<<endl<<endl;
//provide definition
}
int main()
{int clientN,checkN,savingN;
double checkB,savingB,savingR,stock,RE;
cout<<"Enter client number(<0 to exit): ";
cin>>clientN;
while(clientN>=0)
{cout<<"enter checking account number: ";
cin>>checkN;
cout<<"Enter checking balance: ";
cin>>checkB;
cout<<"enter savings account number: ";
cin>>savingN;
cout<<"Enter savings balance: ";
cin>>savingB;
cout<<"Enter yearly interest rate: ";
cin>>savingR;
savingR/=12.;
cout<<"Enter stock holdings: ";
cin>>stock;
cout<<"Enter real estate holdings: ";
cin>>RE;
Portfolio p(clientN,checkN,checkB,savingN,savingB,savingR,stock,RE);
p.display();


cout<<"Enter client number(<0 to exit): ";
cin>>clientN;
}
return 0;

}