![]() |
|
#1
|
|||
|
|||
Hitting a logic problem I can't solveWell, my last lab needs a few tweaks before I can start the next one. It's fairly straightforward, I just can't see why it's doing what it's doing.
CPP / C++ / C Code:
From what I can tell, my add stock method adds the first three stocks I choose to add, and after that the stocks are stored as gibberish. I'd assume the problem is located in that specific method, nothing else should alter that.... so... any help on debugging that one snippet of code would be greatly appreciated. Also, I realize there's no check for stocks of the same name yet. I wanted to get this fixed before I did it. After those two minor fixes, I need to expand the program for my lab due monday. Making it used mixed numbers instead of what it currently uses. I'll post that bit below in case anyone has some basic reccomendations, but my main concern is the above issue. CPP / C++ / C Code:
|
|||
|
#2
|
||||
|
||||
Re: Hitting a logic problem I can't solveI'd suggest (before Dave does
Here is your add code: CPP / C++ / C Code:
Notice your structure is CPP / C++ / C Code:
The second if is redundant. If numActive is not greater than 0 then it must be less than or equal to 0. Alternative structure is CPP / C++ / C Code:
__________________
During the election they said Obama could only be elected when pigs fly. Well, we currently have an epidemic of Swine Flu. Coincidence? |
|
#3
|
|||
|
|||
Re: Hitting a logic problem I can't solveActually that was in there because I planned (and just did) add a check for stocks that were trying to be put in twice. That way I could keep that method from doing anything if IBM was entered multiple times to add.
I finally found my logic error. After a trip to the local bar and a beer my brain untangled and now my add stock works fine. Heh. My code didn't take into account that if say the first entry was a greater hex value than the second, then count would send it out of the array boundaries. It's fixed and works fine now. Now, I just need to add the class mentioned in the first post... and figure out just what on earth we're intended to change about this program. |
|
#4
|
|||
|
|||
Re: Hitting a logic problem I can't solveOk, so.... the lab doesn't make much sense from a "this is a useful change" perspective, it's simply there to teach us to mess with inheritance I think. But, basically we need to add on the ability to convert the stock fractions to mixed numbers. That's mostly implemented here. But, I've got some hangups.
First and foremost.... how do I overload operators to add or subtract mixed numbers? I've looked at examples of how to do it, but I don't understand them. If someone could put it into words for a guy who doesn't know what he's doing at all that'd be helpful. Second..... if I'm overloading operators for add and subtract, I don't know why there's an add method to include. I guess he wants us to send from main two numbers to add, which then adds the numbers.... but then why no subtract also? Meh..... anyway, I can do what I think I'm supposed to do if I just get my operators overloaded, so..... can anyone explain to me how? After that I just have to write a rough main that'll let him test it. Shouldn't be too hard. CPP / C++ / C Code:
|
Recent GIDBlog
Toyota - 2009 May Promotion by Nihal
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Graphic problem in Unreal Tournament 2004 | zerox | Computer Software Forum - Games | 10 | 09-Oct-2005 13:31 |
| a significant problem after installing Xp | mohammad | Computer Software Forum - Windows | 10 | 09-Aug-2005 08:03 |
| String problem | vaha | C Programming Language | 3 | 24-May-2005 19:21 |
| Please help to solve me a problem with multiline texrbox and checkbox | mithila | MS Visual C++ / MFC Forum | 0 | 08-Sep-2004 23:08 |
| logic problem? | ozzytx | C++ Forum | 3 | 09-Jul-2004 03:23 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The