473,383 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

need help with Funcation all around

I have done this . Write a C program that will accept keyboard
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
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4.  
  5. double CollectInput (double a, double i, int n, int Numberofmonths,  int PaymentNumber, int count);
  6. double Calculate (int n,double a, double i,double PaymentAmount,double PaymentNumber, 
  7.          double Numberofmonths, int count, double AmountInterest, 
  8.          double AmountPrinciple, double LoanBlance); 
  9. double Amortization (double a, double InterestRate, double LoanAmount, int PaymentNumber, 
  10.              double AmountPrinciple, double AmountInterest, double LoanBlance, double PaymentAmount); 
  11.  
  12.  
  13. main ()
  14. {
  15.  
  16. int   TermLoan,  // length of the loan
  17.          PaymentNumber,  //number of payments made
  18.           Numberofmonths, //Number of months in the loan
  19.           count,
  20.           n,c; //Letters used for the calculations
  21. double   AmountPrinciple, //Amount paid on principle
  22.          AmountInterest,  //amount paid to interest
  23.          LoanBlance, //amount owed on loan\ count,
  24.          CurrentBlance,
  25.           LoanAmount, //amount of the loan  
  26.          InterestRate, //interest rate on loan
  27.           returnedValue,  a,i,
  28.            PaymentAmount;  //amount paid to loan 
  29.  
  30.  
  31.   CollectInput  (a, i, n, Numberofmonths, PaymentNumber, count);
  32.   returnedValue = CollectInput (a, i, n, Numberofmonths, PaymentNumber, count);
  33.   Calculate (n, a, i, PaymentAmount, PaymentNumber, Numberofmonths, count, 
  34.             AmountInterest, AmountPrinciple, LoanBlance );
  35.  
  36.  
  37.    Amortization (a, InterestRate, LoanAmount, PaymentNumber, AmountPrinciple, 
  38.                  AmountInterest, LoanBlance, PaymentAmount);                         
  39.  
  40.  
  41.  
  42. printf ("hit enter to end");
  43. getchar ();
  44. getchar ();
  45. return 0;         
  46. }
  47.  
  48. //****************************************************************      
  49. //Start of the function to collect data
  50. //****************************************************************
  51. double CollectInput (double a, double i, int n, int Numberofmonths, int PaymentNumber, int count)
  52.      {
  53.       int TermLoan,
  54.            c ;
  55.       double LoanAmount,
  56.              InterestRate,
  57.              CurrentBlance;
  58.  
  59.         while (scanf("%lf%d%lf", &LoanAmount, &TermLoan, &InterestRate) != 3
  60.                      || (LoanAmount < 0 || TermLoan < 0 || InterestRate < 0 ))
  61.           {
  62.              while ((c = getchar()) != '\n' && c != EOF);
  63.              printf ("Please re-enter in loan amount, Term of Loan in months and Interest Rate.\n");
  64.              }
  65.  
  66.  
  67.              CurrentBlance = LoanAmount;
  68.                Numberofmonths = TermLoan; 
  69.                i = InterestRate/ 100;    
  70.                n = Numberofmonths;
  71.                a = CurrentBlance;
  72.                 PaymentNumber = 0;
  73.                 count = 0; 
  74.  
  75.                 return i, n, a, PaymentNumber, count; 
  76.    }  //end of collect data
  77.  
  78.  
  79. //********************************************************************
  80. //Start of Calculate function
  81. //*************************************************************
  82.  double Calculate (int n,double a, double i,double PaymentAmount,double PaymentNumber, 
  83.          double Numberofmonths, int count, double AmountInterest, 
  84.          double AmountPrinciple, double LoanBlance)              
  85.    {
  86.  
  87.  
  88.          PaymentAmount = ((i/12*a)/(1-pow((1+(i/12)),-n)));            
  89.  
  90.             while(PaymentNumber < Numberofmonths)
  91.              {
  92.  
  93.              PaymentNumber++; //Start number of months for amortization schedule
  94.              count++;
  95.              AmountInterest = a  * (i/12);  
  96.              AmountPrinciple = PaymentAmount - AmountInterest;
  97.              LoanBlance = a - AmountPrinciple;
  98.              a = LoanBlance; 
  99.              return a, PaymentNumber, LoanBlance, PaymentAmount, 
  100.                    AmountPrinciple, AmountInterest; 
  101.                 }//end of while loop 
  102.    } //end of Calculate Function
  103.  
  104.  
  105. //*********************************************************************
  106. //State of print function
  107. //************************************************************
  108. double Amortization (double a, double InterestRate, double LoanAmount,  int PaymentNumber, 
  109.         double AmountPrinciple, double AmountInterest, double LoanBlance, double PaymentAmount)
  110. {
  111.           printf ("\amortization Schedule\n");
  112.             printf ("_____________________\n");
  113.            printf ("CurrentBlance %.2f\n", a);
  114.            printf ("InterestRate %.2f\n", InterestRate); 
  115.           printf ("PaymentNumber %d\n",  PaymentNumber);
  116.           printf ("LoanBlance  %.2f\n", LoanBlance);
  117.           printf ("PaymentAmount %.2f\n", PaymentAmount);
  118.           printf ("AmountPrinciple %.2f\n", AmountPrinciple);
  119.           printf  ("AmountInterest %.2f\n", AmountInterest);
  120.           printf ("_______________________\n\n");
  121.  
  122.           return 0;
  123. } //end of Amortization print function
  124.  
  125.  
  126.  
  127.  
Sep 20 '06 #1
0 1993

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: ANt | last post by:
Hi, we have some major GC issues at present with a system we're trying to put live. It's a live calculation engine that's distributed across about 30 Java server processes. A set of processes...
10
by: Nikita A. Visnevski | last post by:
Hi everyone, I am rather new to Java beans. Just picked up a book last night and started reading about them. I am building an application that allows a user to define objects with dynamic...
4
by: kazack | last post by:
I posted a similiar question in this newsgroup already and got an answer which I already knew but didn't get the answer I was looking for so I am reposting the code and question differently in the...
6
by: Jeff | last post by:
Hi, does anyone know why this: <a onclick="insertatcaret(window.opener.document.formname.fieldname,'<td class="header">')">text</a> returns a "Unterminated String Constant" error message in IE...
3
by: Steve | last post by:
i pulled an example off the web and modified it somewhat and whats killimg me is that sometimes it works and sometimes it doesnt. the following is the only line that allows this thing to work over...
5
by: Confused User | last post by:
I am working on device that utilizes a Motorola 68HC16 microcontroller. I am using an old unsupported piece of crap Whitesmith's / Intermetrics / Tasking compiler. The embedded compiler business...
48
by: Chad Z. Hower aka Kudzu | last post by:
A few of you may recognize me from the recent posts I have made about Indy <http://www.indyproject.org/indy.html> Those of you coming to .net from the Delphi world know truly how unique and...
7
by: Jack Addington | last post by:
I've got a fairly simple application implementation that over time is going to get a lot bigger. I'm really trying to implement it in a way that will facilitate the growth. I am first writing a...
0
by: mike.hudson | last post by:
I'm looking for an example of how to call a SAP RFC from within a C# program. If I have a function called "MyFunction" and it takes 1 input parameter and returns one output parameter (a table) how...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.