By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,631 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

beginner c++ homework questions... if anyone knows how to do this, any help would be greatly appreciated TIA

P: n/a
Here is my assignment. I am hoping that someone here quickly knows
all of the correct answers... especially for question #5 and
everything after. Thanks in advance.

__________________________________________________ __________________________________________________ _______________
class Money

{

public:

friend istream& operator >> (istream& IS, Money& anAmount) ;

private:

int mDollars;

int mCents;

};

class ISPAccount

{

public:

friend istream& operator >> (istream& IS, Money& anISPAccount) ;

private:

string mUser ;

Money mBalance ;

int mOnline ;

};

template <class Thing>

class AccountList

{

public:

private:

vector <Thing> mSomeAccts ;

};

1) Write a line of code that declares an AccountList object of
ISPAccounts. Call the object theAccounts.

2) Write a public function in the AccountList class that returns the
index of an ISPAccount parameter. If the ISPAccount is not in the
mSomeAccts vector, return -1. Name the function getIndex. Note that
you will need to add some functionality to the ISPAccount class.

3) Write a function in the AccountList class that will return the
total of all the balances in an AccountList. Call the function
getTotalBal. Note that you will need to add some functionality to the
ISPAccount class and/or the Money class.

4) Write a default constructor for the Money Class that initializes
a Money object to $0.

5) Overload the default constructor so that it takes two arguments,
the first for the number of dollars and the second for the number of
cents.

class BunchOfCards

{

public:

friend vector<Card> operator + (vector<Card> B1, vector<Card> B2) ;

private:

vector <Card> mTheCards ;

// the “top” of the bunch is the last item on the Card on the
vector.

};

6) Write a member function that ‘splits’ a bunch of card in half. The
top half of the bunch is deleted from the bunch and then returned.
Consider the middle index of the bunch equal to mTheCards.size() / 2.
Here’s a sample function call:

{

BunchOfCards aBunch(“the_deck.txt”);

// creates and initializes a BunchOfCards from a file named
the_deck.txt

// that has 36 cards.

BunchOfCards anotherBunch ; // creates an empty BunchOfCards

anotherBunch = aBunch . topHalf() ;

// post condition: anotherBunch contains 18 cards taken off the

// top of aBunch. aBunch contains the 18 cards left on the bottom of
aBunch.

}

7a) Overload the + operator so that it adds two bunches of cards
together.

friend vector<Card> operator + (vector<Card> B2, vector<Card> B2) ;

7b) Rewrite the header making good style and efficient use of const
and &.

8) Write a member function of the BunchOfCards called cut that takes
the top half of a BunchOfCards object and puts it on the bottom.

(Question 9 is not related to any of the classes above)

9) Write a nonmember, templated function that will reverse the order
of a vector of anything

__________________________________________________ __________-
once again, thanks any help!

--n3tb1n

Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
N3TB1N wrote:
[do my homework redacted]


You forgot to post your instructors email address so we could mail it directly
to him.
Jul 22 '05 #2

P: n/a
N3TB1N <45*********@60x.5K> wrote in
news:vb********************************@4ax.com:
Here is my assignment. I am hoping that someone here quickly knows
all of the correct answers... especially for question #5 and
everything after. Thanks in advance.

(...)

What's the difference *for you*, if you wouldn't have done your homework
yourself, or somebody'd have done it for you instead?

Please, tell us here on the newsgroup!
Jul 22 '05 #3

P: n/a
On Sun, 09 May 2004 02:03:11 -0400, N3TB1N <45*********@60x.5K> wrote:
Here is my assignment. I am hoping that someone here quickly knows
all of the correct answers...
In answer to your question, yes I do know all of the correct answers.
Depending on exctly what you want me to do, my rates go up to about
GBP 200 per hour.
especially for question #5 and everything after. Thanks in advance.
_________________________________________________ __________________________________________________ ________________

class Money
{
public:
friend istream& operator >> (istream& IS, Money& anAmount) ;

private:
int mDollars;
int mCents;
};
[snip]
4) Write a default constructor for the Money Class that initializes
a Money object to $0.
I assume that you are reasonably confident about doing this.
5) Overload the default constructor so that it takes two arguments,
the first for the number of dollars and the second for the number of
cents.
When you have anwered Q4, you will have a default constructor for the
Money Class that initialises a Money object to $0.00.

For Q5 you need to "overload" the constructor. If you don't
understand "overload" look it up or ask your instructor to explain.

Your overloaded constructor will have two arguments. If you don't
understand "argument" look it up or ask your instructor to explain.
Your first argument will be a number of dollars and your second
argument will be a number of cents.

Remember that this is an overloaded *constructor* so you are going to
have to think about what you are going to do with the two arguments
(one for dollars and the other for cents) in the context of
initialising a Money object.

When you have thought about that you should be in a position to write
the overloaded constructor that your instructor asked you for.

rossum

_________________________________________________ ___________-
once again, thanks any help!

--n3tb1n


--

The Ultimate Truth is that there is no Ultimate Truth
Jul 22 '05 #4

P: n/a
N3TB1N wrote:
Here is my assignment. I am hoping that someone here quickly knows
all of the correct answers... especially for question #5 and
everything after. Thanks in advance.

[assignment deleted]

Pathetic.

--Steve
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.