http://www.pastebucket.com/21551 Im having bringing this program together. I hav
ID: 3543397 • Letter: H
Question
http://www.pastebucket.com/21551
Im having bringing this program together. I have to make two functions one for the header and another for the table. The table function should pass the input parameter of double. I have solved how to get the day from the users input. I have the formulas listed in the notes section. Help would be apprecitated. Thank you. (this program is pennies doubling each day) starting from 0.01, 0l.02, 0.04, 0.08 and accumulates . The balance should be adding the pennies up 0.01, 0.03, 0.07....
Explanation / Answer
please rate - thanks
had to tweak formulas a little because didn't know what (first term meant)
changed amount to double - money is real
any questions ask
/***
Notes: Deposit: f(x)= 0.01 (2^x) where x is the number of days
Days: x = log base 2 (amount)
Balance: x = (first term)(1-r^n)/ (1-r) example:
***/
#include <stdio.h>
#include <math.h>
int b = 2;
int days;
int x;
double a, dep, bal,amount;
void header();
void table();
int main(void)
{int days;
header();
table();
return 0;
}
void header() {
printf("Please enter the amount of money you want to accumulate: ");
scanf("%lf", &amount);
amount*=100;
days = (log2((amount)))+1;
dep = 0.01*days;
bal = b*((1-b ^ days) ) / (1-b );
printf("It took %d days to accumulate at least $%.2f ", days, amount/100);
}
void table(){
bal=0;
dep=.01;
printf("DAY DEPOSIT BALANCE ");
printf("--- ------- ------- ");
for (x = 1; x <= days; x++){
bal=bal+dep;
printf("%d %.2f %.2f ", x,dep,bal);
dep=dep*2;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.