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.
//checkbookagain.cpp
#include <iostream>
using namespace std;
int main ()
{
double with = 0;
double *wAmt = new double[with];
double dep = 0;
double *dAmt = new double[dep];
cout << "How many withdrawals were made? ";
cin >> with;
cout << "How many deposits were made? ";
cin >> dep;
for (int i=0; i<with; i++)
{
cout << "Enter in the amount of withdrawal " << i + 1 << ": $";
cin >> wAmt[i];
}// end for
for (int j=0; i<dep; j++)
{
cout << "Enter in the amount of deposit " << j + 1 << ": $";
cin >> dAmt[j];
}//end for
for (i=0; i<with; i++)
{
cout << "Withdrawal " << i + 1 << ": $";
cout << wAmt[i] << endl;
}//end for
for (j=0; j<dep; j++)
{
cout << "Deposit " << j+1 << ": $";
cout << dAmt[j] << endl;
}//end for
return 0;
}//end of main function
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. I tried moving
cout << "How many deposits were made? ";
cin >> dep;
farther down after the loop for withdrawals, but that just made the program ask for more deposits than were inputted.
How to I organize these two arrays to get them to properly display? Thanks