Anybody Know Any C++ Programming?

thanks for the help.

heres the deal.

the assignment reads: Implement a SavingsAccount class to help keep track of a banks customer account information. Its constructor should take as parameters the customers ame and address, the amount of money in the account and the interest rate.

it tells us to include member functions Deposit, Withdrawal, accumulate, interest, and print_account_info. we are given the interest formula and the interest rate we are supposed to use.

Now the deposit and withdrawl functions are fairly easy. i just added/subtracted the amount from a float variable "balance"

Basicly i have no idea how to go about making the constructor and my book is not much help ive read it like 3 times.

 
Originally posted by Mac11 thanks for the help.

 

 

heres the deal.

the assignment reads: Implement a SavingsAccount class to help keep track of a banks customer account information. Its constructor should take as parameters the customers ame and address, the amount of money in the account and the interest rate.

 

it tells us to include member functions Deposit, Withdrawal, accumulate, interest, and print_account_info. we are given the interest formula and the interest rate we are supposed to use.

 

Now the deposit and withdrawl functions are fairly easy. i just added/subtracted the amount from a float variable "balance"

 

Basicly i have no idea how to go about making the constructor and my book is not much help ive read it like 3 times.
K.. the constructor has a default (no params passed in) but can be defined to allow things to be passed in.. typically those would be used to 'seed' data.. In this case, the client name, initial balance, and interest rate..

I'm not sure why you would have to seed it if you also have to make a method that allows you to change the interest.. other than there is no way to modify the name (not a bad thing in this case, so the constructor would still be a good way to do it)..

So, here might be your definition of the class.. (note that the .... are just for indenting since we can't have various spaces in the messages)

class clAccount_t

{

....private:

..... char _caName[256];

..... char _caAddress[256];

..... float _fInterestRate;

..... float _fBalance;

..... public:

// you might need to 'throw' an exception in here, constructors can't return anything.. if not, you should be ok..

...... clAccount(char *pcName, char *pcAddy, float fInterest, float fBalance)

..... {

........... // error checking, validate input.. make sure name is there, and

........... // the numbers are >= 0 for balance, and >0 for interest

........... sprintf(_caName, "%s", pcName); // note, if it's not a null terminated string you will have to do a memcopy, and have to have the name size passed in..

............ sprintf(_caAddress, "%s", pcAddy);

............ _fInterestRate = fInterest;

............ _fBalance = fBalance;

..... }

..... // not sure if you have to return values from your methods for error checking or not.. but you define them here.. I'll be defining as voids..

..... void vDeposit(float fDepValue);

..... void vWithdraw(float fWithdrawValue);

..... etc etc etc

} // end class

Hope that helps.. If you have any more questions, let me know..

Oh, and since this is all in memory, and if the system goes down you loose your accounts, does the teacher want you to keep track of it on disk? or just make sure after running a few calls of various methods that the final output is right...

 
The method definitions would go in a .C file.. the prototypes and class definition in a .H file..

You might want/need to define the constructor in the .C file... not an issue.. you just put the class type::method(){}...

ie

//constructor...

clAccount_t::clAccount_t(char *, char *, float, float)

{

.. blah blah

}

// withdraw.. remeber to do the error checking and such..

void clAccount::vWithdrawl(float fWithdraw)

{

..... _fBalance +- fWithdraw;

}

EDIT: the reason for mentioning the constructor in the .C file is that you 'can' define it in the .H file.. you can 'not' set values of variables there, it has to be done someplace else.. Normally the constuctor calls some internal "initialize" method that sets all the private/public vairables to some default value..

 
that was remarkably close to what i actually came up with. most of my deviations wer strictly function names and that sort of thing. i used all void functions because my error checking methods in fact did not need to return a value just as you assumed. and we dont have to keep track of anything. we were given a specific test case with customer name, address and when they made which type of transactions so it doesnt have to have any kind of backup. Thanks a bunch for the help!!

-Mac

 
Not a problem //content.invisioncic.com/y282845/emoticons/smile.gif.1ebc41e1811405b213edfc4622c41e27.gif Hope that helped //content.invisioncic.com/y282845/emoticons/smile.gif.1ebc41e1811405b213edfc4622c41e27.gif

 
I am just a high school student (got a 5 on the ap exam too) and have always thought and been told that floats are useless....why not just make it a double.....I dont have a lot of real world experiment, seems like this may not hold true? --on a side note I will be entering University of Illinois' eningeering program in the fall (5th best school in the nation I might add //content.invisioncic.com/y282845/emoticons/smile.gif.1ebc41e1811405b213edfc4622c41e27.gif )--anyways, the decisions doesn't have to be made right away, but how I am stuck between computer eningeering, comp sci and possibly electrical eningeering....anyone want to add anything that mught pursuade me one way or another?

 
Originally posted by evo2k3 the decisions doesn't have to be made right away, but how I am stuck between computer eningeering, comp sci and possibly electrical eningeering....anyone want to add anything that mught pursuade me one way or another?
i dont want to influence you one way other the other but ill give you a little better view of what each field is all about. you have to just choose what you like to do better. take a wide range of classes to see what you like.

basicly here is the difference:

CSCI: higher level. mostly programming oriented. work with C++, java, openGL and other programming languages to make programs.

CE: lower level. mostly hardware devlopment/ building/design oriented. learn to design and build components working with the electrical structure of a computer. a lot of wrapping small wirea up and making diodes and stuff.

EE: i dont know a whole lot about but it is a more broad field then Computer Engineering and you will learn a lot of different electrical principals and structures.

any other questions let me know.

-Mac

University of Indianapolis

 
Originally posted by evo2k3 I am just a high school student (got a 5 on the ap exam too) and have always thought and been told that floats are useless....why not just make it a double.....I dont have a lot of real world experiment, seems like this may not hold true? --on a side note I will be entering University of Illinois' eningeering program in the fall (5th best school in the nation I might add //content.invisioncic.com/y282845/emoticons/smile.gif.1ebc41e1811405b213edfc4622c41e27.gif )--anyways, the decisions doesn't have to be made right away, but how I am stuck between computer eningeering, comp sci and possibly electrical eningeering....anyone want to add anything that mught pursuade me one way or another?
Float is mostly old ANSI C.. yes, double (C++) works just as well .. they are both capable of floating point operations.. on the PCs, double is 32 bits (IIRC) but float is just 16? depends on the size of the number you are gonna store.. *shrug* If you want to find out fast, just write a tiny app that does a cout on the sizeof() and sizeof()... I could be mistaken about float being ANSI C, but I'm pretty sure that's right.. Most of what I do is with whole numbers (even decimals, they are converted to rational numbers by our customers, we deal with 100ths of seconds, but full counts.. that make sense? So float and double I'm still fuzzy on, haven't used them in over 3 years //content.invisioncic.com/y282845/emoticons/wink.gif.608e3ea05f1a9f98611af0861652f8fb.gif

As for where to go.. depends on what you want to do every day.. CompSci is geared more toward free-form work places with diversity (depending on where you go).. Engineering is much more rigid (from what I gather).. Computer Engineering might be interesting, depending on where you can get a job.. might be working on some nifty tech.. perhaps with electrical as well, but that's a lot broader (better highering possiblities?) and could have you doing some pretty boring stuff..

Mostly it all depends on you.. what do you like doing the most? Trying to solve a question that could take you years to get an answer to and requires a LOT of math, or solving problems that take a few weeks to a few months to get an 'answer' to, then spend a few weeks to a few months generating the solution (ie. writing the code)..

I my self prefer the CompSci of it all, don't like math that much..

 
nice

ill trade you a jl 500/1 for a copy of that program?//content.invisioncic.com/y282845/emoticons/biggrin.gif.d71a5d36fcbab170f2364c9f2e3946cb.gif :D //content.invisioncic.com/y282845/emoticons/biggrin.gif.d71a5d36fcbab170f2364c9f2e3946cb.gif

 
Activity
No one is currently typing a reply...

About this thread

Mac11

10+ year member
MacGyver
Thread starter
Mac11
Joined
Location
Outside Chicago
Start date
Participants
Who Replied
Replies
13
Views
481
Last reply date
Last reply from
Mac11
IMG_1882.jpeg

slater

    Oct 4, 2025
  • 0
  • 0
Screenshot_20251004_120904_Photo Translator.jpg

1aespinoza

    Oct 4, 2025
  • 0
  • 0

New threads

Top