Hello... I am working on a For Loop Problem.. I have tried modifying it in many ways for it to work - but it still doesn't ... any help would be appreciated..
The problem: To make a For Loop that asks for an initial amount input.. ex. $.01. It will double that amount every day for 30 days... 3 columns need to be displayed - the day - the input - the total...
ex. day input total
1 .01 .01
2 .02 .03
3 .04 .07
4 .08 .15 etc...
This is the code I have so far:
#include<iostream.h>
#include<math.h>
main()
{
double daynumber, amountentered=0, depositamount = 0, totalbal = 0, numberofday\
s;
int maxnumberofdays = 30;
cout<<"Please enter input amount"; cin>>amountentered;
cout<<"Day\tDeposit\tTotal\n";
for(numberofdays = 1; numberofdays<=maxnumberofdays; numberofdays++)
double amountentered = depositamount; // making the deposit amount the sames\
as amount entered
depositamount = (2*depositamount);
cout<<numberofdays<<"\t"; cout<<depositamount<<"\t";
cout<<totalbal<<"\t";
amountentered += amountentered;
return 0;
}
When I run the program it asks for the input amount... if I put in .01 as an example the output is:
Day Deposit Total
31 0 0
Any help would be appreciated...
marie10913@aol.com



LinkBack URL
About LinkBacks


