input and display a loan amortization schedule back on the screen. The
program should ask for the Loan Amount (real number), Term of the Loan
in months (integer), and the Interest Rate (real number); the input data
should be validity checked. The output should list a heading showing the
input values, then a separate line indicating Payment Number, Loan
Balance, Payment Amount, Amount to Principle, Amount to Interest, New
Balance for each payment. A loop should be used to display the
amortization list. The payment amount is calculated using the formula:
[ (1 + i / 12) ** n * (i / 12 * a) ] / [ (1 + i / 12) ** n – 1 ]
where i=interest rate, n=number of months, a=current balance
After completing one occurrence the program should exit.
and took it and modified to do 2. Due by the end of week 4. Modify the C program from assignment 1 to use function calls and pass parameters. The following functions should be used:
Collect Input (collect and validate input values),
Calculate a Payment, and
Write Amortization Line
i'm having issues to get my main program to read my funcation. I know that I'm missing the statement to call them in. But I also know that i have to may items to send out data from one funcation to the next. This is done all online so I do not have a teacher or anyone to ask question to. I need some help. I seem to have hit a brick wall and it keeps grow up and up.
Expand|Select|Wrap|Line Numbers
- #include <stdio.h>
- #include <math.h>
- double CollectInput (double a, double i, int n, int Numberofmonths, int PaymentNumber, int count);
- double Calculate (int n,double a, double i,double PaymentAmount,double PaymentNumber,
- double Numberofmonths, int count, double AmountInterest,
- double AmountPrinciple, double LoanBlance);
- double Amortization (double a, double InterestRate, double LoanAmount, int PaymentNumber,
- double AmountPrinciple, double AmountInterest, double LoanBlance, double PaymentAmount);
- main ()
- {
- int TermLoan, // length of the loan
- PaymentNumber, //number of payments made
- Numberofmonths, //Number of months in the loan
- count,
- n,c; //Letters used for the calculations
- double AmountPrinciple, //Amount paid on principle
- AmountInterest, //amount paid to interest
- LoanBlance, //amount owed on loan\ count,
- CurrentBlance,
- LoanAmount, //amount of the loan
- InterestRate, //interest rate on loan
- returnedValue, a,i,
- PaymentAmount; //amount paid to loan
- CollectInput (a, i, n, Numberofmonths, PaymentNumber, count);
- returnedValue = CollectInput (a, i, n, Numberofmonths, PaymentNumber, count);
- Calculate (n, a, i, PaymentAmount, PaymentNumber, Numberofmonths, count,
- AmountInterest, AmountPrinciple, LoanBlance );
- Amortization (a, InterestRate, LoanAmount, PaymentNumber, AmountPrinciple,
- AmountInterest, LoanBlance, PaymentAmount);
- printf ("hit enter to end");
- getchar ();
- getchar ();
- return 0;
- }
- //****************************************************************
- //Start of the function to collect data
- //****************************************************************
- double CollectInput (double a, double i, int n, int Numberofmonths, int PaymentNumber, int count)
- {
- int TermLoan,
- c ;
- double LoanAmount,
- InterestRate,
- CurrentBlance;
- while (scanf("%lf%d%lf", &LoanAmount, &TermLoan, &InterestRate) != 3
- || (LoanAmount < 0 || TermLoan < 0 || InterestRate < 0 ))
- {
- while ((c = getchar()) != '\n' && c != EOF);
- printf ("Please re-enter in loan amount, Term of Loan in months and Interest Rate.\n");
- }
- CurrentBlance = LoanAmount;
- Numberofmonths = TermLoan;
- i = InterestRate/ 100;
- n = Numberofmonths;
- a = CurrentBlance;
- PaymentNumber = 0;
- count = 0;
- return i, n, a, PaymentNumber, count;
- } //end of collect data
- //********************************************************************
- //Start of Calculate function
- //*************************************************************
- double Calculate (int n,double a, double i,double PaymentAmount,double PaymentNumber,
- double Numberofmonths, int count, double AmountInterest,
- double AmountPrinciple, double LoanBlance)
- {
- PaymentAmount = ((i/12*a)/(1-pow((1+(i/12)),-n)));
- while(PaymentNumber < Numberofmonths)
- {
- PaymentNumber++; //Start number of months for amortization schedule
- count++;
- AmountInterest = a * (i/12);
- AmountPrinciple = PaymentAmount - AmountInterest;
- LoanBlance = a - AmountPrinciple;
- a = LoanBlance;
- return a, PaymentNumber, LoanBlance, PaymentAmount,
- AmountPrinciple, AmountInterest;
- }//end of while loop
- } //end of Calculate Function
- //*********************************************************************
- //State of print function
- //************************************************************
- double Amortization (double a, double InterestRate, double LoanAmount, int PaymentNumber,
- double AmountPrinciple, double AmountInterest, double LoanBlance, double PaymentAmount)
- {
- printf ("\amortization Schedule\n");
- printf ("_____________________\n");
- printf ("CurrentBlance %.2f\n", a);
- printf ("InterestRate %.2f\n", InterestRate);
- printf ("PaymentNumber %d\n", PaymentNumber);
- printf ("LoanBlance %.2f\n", LoanBlance);
- printf ("PaymentAmount %.2f\n", PaymentAmount);
- printf ("AmountPrinciple %.2f\n", AmountPrinciple);
- printf ("AmountInterest %.2f\n", AmountInterest);
- printf ("_______________________\n\n");
- return 0;
- } //end of Amortization print function