Advertisement
Guest User

Savannah penny lab

a guest
Oct 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3.  
  4. void outputheader()
  5. {
  6.     /*     add code to output the table header */
  7.     /* --> between here */
  8.     printf("       DAY         DEPOSIT         BALANCE\n");
  9.     printf("       ---         -------         -------\n");
  10.         /* <-- and here */
  11. }
  12.  
  13. int generatetable(double targettotal /* add parameter here */)
  14. {
  15.     /*     add declarations and code to generate the table */
  16.     /*     (based on the parameter value) */
  17.     /*     and return the number of days required to accumulate the specified amount */
  18.         /* --> between here */
  19.     double balance, deposit;
  20.     int days;
  21.     balance = 0.00;
  22.     deposit = 0.01;
  23.     days = 1;
  24.  
  25.     while (balance < targettotal) {
  26.         balance += deposit;
  27.         printf("%10d         %7.2lf      %15.2lf\n", days, deposit, balance);
  28.         ++days;
  29.         deposit *= 2;
  30.     }
  31.    
  32.         /* <-- and here */
  33. }
  34.  
  35. int main(void)
  36. {
  37.     /*     add declarations and code to input the amount of money, */
  38.        /*     call the function to output the table header, */
  39.        /*     and call the function to generate the table, */
  40.        /*     and print the number of days required */
  41.     /* --> between here */
  42.     double targettotal;
  43.  
  44.     scanf_s("%lf\n", &targettotal);
  45.  
  46.     generatetable(double);
  47.    
  48.  
  49.  
  50.     /* <-- and here */
  51.  
  52.    
  53.  
  54.     while (1) getchar();
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement