Write a program that calculates how many days it takes to accumulate at least $1,000,000 if someone deposits one penny on the first day, two pennies the second day, four pennies on the third day and continues to double each day. The output should display the number of days.


Java Script.

Respuesta :

Answer:

#include<stdio.h>

int DaysRequired(double);

void tableHeader();

void tableHeader(){

       printf("DAYS     DEPOSIT         BALANCE  \n");

}

int DaysRequired(double money){

       double deposit=0.01;

       double balance=0.01;

       int days=1;

       tableHeader();

       printf("%-10d%-15.2f%-15.2f\n",days,deposit,balance);

       while(balance<money){

               days++;deposit*=2;balance+=deposit;

               printf("%-10d%-15.2f%-15.2f\n",days,deposit,balance);

       }

return days;

}

int main(){

       double amount;

       int days;

       printf("Enter Amount of money you want to Accumulate :");

       scanf("%lf",&amount);

       days=DaysRequired(amount);

       printf("No of Days Required %d\n",days);

return 0;

}

Explanation:

See attached image for the output

Ver imagen igeclement43