Sunday, August 2, 2009

Please help!!! C++ Assignment?

I need help with this question. %26gt;"%26lt;





This is the instruction:


1.Your review of the program "main" will reveal that an array of "Account" objects is created; group[6].


- add a loop to the main( i.e. for loop) to create a deposit for each group element.


- add a loop to the main( i.e. for loop) to output the balance of each group element.


- the output loop should also identify which group element is being output.





ex.


Group 1 Account:


Balance : 300





Group 2 Account:


Balance : 600


===============================


#include %26lt;iostream%26gt;


using namespace std;


class Account


{


long balance;


public:


void deposit (long amount)


{


balance += amount;


}


void withdraw (long amount)


{


balance -= amount;


}


void status ()


{


cout %26lt;%26lt; "balance : " %26lt;%26lt; balance %26lt;%26lt; endl;


}





Account (long initialAmount = 0)


{


balance = initialAmount;


}


~Account ()


{


cout %26lt;%26lt; " transfer " %26lt;%26lt; balance %26lt;%26lt; " to manager " %26lt;%26lt; endl;


}


};


int main ()


{


Account mine, yours (100), group[6];





mine.deposit (500); // now balance should be 500





mine.status (); // "The balance is : 500"





yours.status (); // "The balance is : 100"





yours.deposit (300);


yours.status (); // "The balance is : 400"





mine.withdraw (600); // now in the red





mine.status (); // "The balance is : -100"





return 0;


}

Please help!!! C++ Assignment?
I am confused as to how you can understand how to make object method calls and not know how to use a loop.





Here is the first loop to get you started but it is your job to do your assignments.





for (int i = 0; i %26lt; 6; ++i)


{


group[i].deposit(100);


}
Reply:What's your question?


No comments:

Post a Comment