home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / c / c_tutor / examples / menu < prev    next >
Encoding:
Text File  |  1992-11-14  |  1.9 KB  |  73 lines

  1. /*
  2. **              menu to print amortization
  3. **              selecting whether to compute payment or not.
  4. **
  5. **
  6. amount = starting balance
  7. balance = remaining balance
  8. rate = interest rate per period
  9. rate1 = interest rate per year
  10. payment = monthly payment
  11. principal = payment to principle
  12. interest = payment of interest per period
  13.  
  14. *******************************************************
  15. *               declare variables               */
  16.  
  17.         float amount = 0;
  18.         float balance = 0;
  19.         float rate1 = 0;
  20.         float rate = 0;
  21.         float payment = 0;
  22.         float principal = 0;
  23.         float interest = 0;
  24.  
  25.  
  26.  
  27. /*      **************************      */
  28. main()  /*      rename to menu()        */
  29.  
  30.         {
  31.         int answer;
  32.  
  33.         float pymt();
  34.         float interest1();
  35.  
  36.                 scroll();               
  37.  
  38.                 printf("Would you like me to figure the payment, Y or N ? ");
  39.  
  40.                 answer = getchar();
  41.                 answer = toupper(answer);
  42.                 scroll();
  43.                 if ((answer != 'Y') && (answer !='N') )
  44.                         main();
  45.                         
  46.                         printf("What is the amount of the loan ? ");
  47.                         scanf("%f",&amount);
  48.  
  49.                         printf("What is the annual interest rate ? ");
  50.                         scanf("%f",&rate1);
  51.                         rate = (rate1 * .01)/12;
  52.  
  53.                         if (answer == 'Y')
  54.                         pymt(amount,rate);
  55.                 else
  56.                         {
  57.                         printf("What is the monthly payment ? ");
  58.                         scanf("%f",&payment);
  59.                         }
  60.  
  61.         interest1(amount,rate,payment);
  62.  
  63.         }
  64.  
  65.  
  66.         scroll()
  67.                 {
  68.                 int screen = 0;
  69.                                 while (++screen <26)
  70.                         printf("\n");
  71.                 }
  72.  
  73.