Using two arrays

I'm working on a problem to balance a checkbook. I've been struggling with it so I split it up into its components. I first made an array to store withdrawals. When I ran this program, everything ran fine. Now I'm trying to create a second array to store deposits. I can't get it to display properly.

 ``123456789101112131415161718192021222324252627282930313233343536373839404142434445`` ``````//checkbookagain.cpp #include using namespace std; int main () { double with = 0; double dep = 0; cout << "How many withdrawals were made? "; cin >> with; cout << "How many deposits were made? "; cin >> dep; double *wAmt = new double[with]; double *dAmt = new double[dep]; for (int i=0; i> wAmt[i]; }// end for for (int j=0; i> dAmt[j]; }//end for for (i=0; i

When its this way, it lets me input everything up to the deposits. When it gets to the deposit input, it just displays some numbers in scientific notation and I'm not sure why.
First off it doesnt look like you are using a IDE cause when i copyed and pastes your code i got a few compiler errors for in lines 8 and 9 your code is:
 ``12`` ``````double with = 0; double dep = 0;``````

now the problem is not that you declared then double but that you ask for a whole number question...what if user entered 2.5....YOU CAN'T HAVE HALF AN ARRAY. so those need to be int.

Also your problem is on line 26
`for (int j=0; i<dep; j++)`
now first off the declared variable in this loop is j but your checker is i?and to further the destruction your last loop is
`for (int i=0; i<with; i++)`
so if i had to guess when you run it is using the last i but you cant use the i in THAT scope.

And also you need to use the delete keyword to delete the memory you allocated in new.....so write
 ``12`` ``````delete wAmt[]; delete dAmt[];``````

Im sorry if i was mean but i just told it how it was...also some advice would be to get you a compiler....it makes things 100 times easier!

Hope this helps
Thank you so much! That helped. My only problem is .. when I compile it I get 0 errors so I'm not sure if that's bad since you say you got 8? Also.. where do I insert the

 ``12`` ``````delete wAmt[]; delte dAmt[];``````

I tried putting it after the last loop, but it gave me a compiling error. The error was:
error c2059: syntax error : ']'
Okay well I have this program about done, but I am reaching one final roadblock.

I need to display the beginning balance, the ending balance AND the balance after each deposit/withdrawal.

I have the beginning balance and ending balance, but I'm not sure what approach to take for the balance after each transaction.

Right now, I did this:

 ``123456`` ``````double *newBala = new double[with]; ... for (i=0; i

The problem with this is that for each transaction it only shows the beginning balance minus the withdrawal.. not minus the cumulative total of the withdrawals (and same situation for the deposits). How do I get the withdrawals to change the balance after each transaction?
Topic archived. No new replies allowed.