DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Oct 2005
    Posts
    2

    Need Help With Multi Function Program

    I have been going crazy all night and a good part of today. I can't get pass the build, I think I have my functions wrong. Can someone Please Help Me. I am going nuts. Here is what I have for code.

    Thanks

    Code:
    #include "stdafx.h"
    #include <math.h>
    
    //#using <mscorlib.dll>
    
    //using namespace System;
    
    void display_statement (double, double, double, double, int, double);
    double Tinterest_paid(double, int);
    double payment_amount (double, double, int);
    
    
    
    int main(void)
    
    {
    double a=1;
    double b=1;
    double c=1;
    double d=1;
    double e=1;
    double x=1;
    double i;                     // Interest_Rate Monthly
    double p;                     // Principal
    int n  ;                      // Number Payments display_statement
    double Payment_Amount;
    double payment;
    double Total_Amount;
    double total_amount;
    double Tamount_paid;
    double total_interest;
    double Tinterest_paid(double, int);
    double payment_amount (double, double, int);
    
    
    	printf("Please Enter Interest Rate ");            // Key As n.n
    		scanf("%lf",&i);
    	printf("Please Enter Loan Amount ");              // Amount of Loan
    		scanf("%lf",&p);
    	printf("Please Number Of Monthly payments ");     // Number Of Monthly 
    		scanf("%d",&n);
    
    	payment = Payment_Amount (i,p,n);
        Total_Amount = Tamount_paid(payment,n);
        total_interest=Tinterest_paid(total_amount,p);
    
    void display_statement (double, double, double, double, int, double);
    
    }
    
    {
    	double x;
    
    	x = Tinterest_paid(200000, 150000);
    	printf("The result is\n\n %f', X);
    
    		return 0;
    
    
    
    }
    
    double Tinterest_paid (double amount_paid, double Principal)
    
    {
    
    	double int_paid;
    
    	int_paid = amount_paid - Principal;
    
    	return (int_paid);
    
    {
    
    	double x;
    	x = Payment_Amount(5.5, 100000, 60);
    
    }
    
    double Payment_Amount (double Interest_Rate, double Principle, int Number_Payments)
    
    {
    	double a, payment;
    
    	a = Interest_Rate/100;
    	a= a/12;
    
    	payment = (a* Principle)/ (1 - pow((1+a), -Number_Payments));
    	return(payment);
    }
    
    {
    	display_statement (a, b, c, d, x, e);
    	return 0;
    
    }
    
    void display_statement (double payment, double loan_payment, double Tinterest, double Principal, int Number_Payments, double interestrate)
    
    {
    
    	printf("Monthy Payment: $%.2f\n\n", payment);
    	printf("Total Loan Amount; $%.2f\n\n", loan_Amount);
    	printf("Total Interest Payment: $%.2f\n\n", Tinterest);
    	printf("Principal: $%.2f\n\n", Principal);
    	printf("Number Of Payments: %d\n\n", Number_Payments);
    	printf("Interest Rate %.3f percent\n\n", interestrate);
    
    }

  2. #2
    Join Date
    Oct 2005
    Posts
    173
    Code:
    void display_statement (double, double, double, double, int, double);
    double Tinterest_paid(double, int);
    double payment_amount (double, double, int);
    for starters, what's wrong with this picture? ;)
    also keep in mind case sensitivity.

  3. #3
    Join Date
    Oct 2005
    Posts
    2
    Not sure I been at this for the last 13 hours, I am starting to see double. Could you please Help.

    Thank You

  4. #4
    Join Date
    Oct 2005
    Posts
    173
    your function prototype is not the same as your function definition.





    payment = Payment_Amount (i,p,n);
    Total_Amount = Tamount_paid(payment,n);
    total_interest=Tinterest_paid(total_amount,p);

    void display_statement (double, double, double, double, int, double);

    }

    also, why is this prototype here?
    Last edited by rssmps; 10-13-2005 at 03:47 PM.

  5. #5
    Join Date
    Oct 2005
    Posts
    32
    Hi
    Sorry... my English language is bad
    I am spend to much time to correct your mistake, but I am don't know what your programming doing exactly.
    Be careful to next notes:
    1- some time you declare variable "double" and try to use it "int".
    2- don't use variable and function same name you will confused.
    3- Use one way to give the variable name, don't use x,s,w1…

    The program is work now but, must you complete it
    I have wrong result when use "scanf" ??? I used "cin"

    Finally I try to help you if I am do mistake in my replay I am sorry
    Code:
    // program for do something
    //by your name
    
    #include "stdafx.h"
    #include <math.h>
    #include <iostream.h>
    
    
    // Declare functions only 
    
    // function1 for ...
    double Payment_Amount (double,double,int);
    //function2 for ...
    double Tinterest_paid(double, double);
    // function1 for ....
    void display_statement (double, double, double, double, double, double);
    
    
    
    
    // Declare variables only 
    
    //double total_amount,total_interest;   // your don't used these variables
    //double Payment_Amount; //have same function name .
    
    int n ;												 // Number Payments display_statement
    double Total_Amount,Tamount_paid,p,i,payment;
    double a=1,b=1,c=1,d=1,e=1,int_paid=1;							// Interest_Rate Monthly
    
    
    
    int main(void) {
    
    //scanf("%lf",&p);
    
    	printf("Please Enter Interest Rate ");            // Key As n.n
    	//		scanf("%lf",&i);
    	cin >> i;
    	
    	printf("Please Enter Loan Amount ");              // Amount of Loan
    	//	scanf("%lf",&p);
    	cin >> p;
    				
    	printf("Please Number Of Monthly payments ");     // Number Of Monthly 
    //		scanf("%lf",&n);
    	cin >> n;
    
    	
    	payment = Payment_Amount (i,p,n);
    	printf("%f\n",payment);  
    	
    	
    	 //Total_Amount = Tamount_paid(payment,n);   //don't used
        
    	 //total_interest=Tinterest_paid(total_amount,p); //don't used
    
    
    	 
    		int_paid = Tinterest_paid(200000, 150000);
    	
    		printf("The result is %f\n", int_paid);
    
    		display_statement (a, b, c, d, int_paid, e);
    
    	return 0;
    
    }
    
    //function 1 
    double Payment_Amount (double Interest_Rate, double Principle, int Number_Payments)
    
    	{
    	
    		a = (Interest_Rate/100)/12;
      
    		payment = (a * Principle)/ (1 - pow((1+a),-Number_Payments));
     
    		return (payment);
    	}
    
    // function2 
    double Tinterest_paid (double amount_paid, double Principal)
    
    	{
    	int_paid = amount_paid - Principal;
    
    	return (int_paid);
    	}
    
    // function 3
    void display_statement (double payment, double loan_payment, double Tinterest, double Principal, double Number_Payments, double interestrate)
    
    {
    
    	printf("Monthy Payment: $%.2f\n\n", payment);
    	printf("Total Loan Amount; $%.2f\n\n", loan_payment);
    	printf("Total Interest Payment: $%.2f\n\n", Tinterest);
    	printf("Principal: $%.2f\n\n", Principal);
    	printf("Number Of Payments: %d\n\n", Number_Payments);
    	printf("Interest Rate %.3f percent\n\n", interestrate);
    
    }
    
    
    
    /*
    	double x;
    	x = Payment_Amount(5.5, 100000, 60);
    
    }
    
    
    
    	
    	{
    	return 0;
    	}*/
    
    
    	 /*  void display_statement (double, double, double, double, int, double);
    		{
    		
    		}
    
    
    	//	double x;
    
    */

Similar Threads

  1. call function for button
    By angela_quests in forum VB Classic
    Replies: 2
    Last Post: 04-13-2007, 04:57 AM
  2. comparing function pointers [was: typedef problem]
    By swapnil_paranja in forum C++
    Replies: 20
    Last Post: 08-25-2005, 03:54 PM
  3. Replies: 0
    Last Post: 06-22-2000, 07:30 AM
  4. Trying to print a PDF File from VB
    By Kunal Sharma in forum VB Classic
    Replies: 2
    Last Post: 04-25-2000, 03:45 PM
  5. I am helpless - Edit Info form
    By Dan in forum VB Classic
    Replies: 0
    Last Post: 03-17-2000, 05:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links