Thread: Need more eyes to find problem??

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    4

    Question Need more eyes to find problem??

    I have been working on this problem all weekend, and just cant see what I am doing wrong. I am very new to programming, so that is my excuse.

    I am using VC++ and here is the code I have put together. It compiles fine but the calculation is all messed up. I have know idea what I am doing wrong???? I sure hope this pastes right???

    Code:
    /*************header files**************/
    
    #include <iostream>
    
    using namespace std;
    
    
    //constants defined
    
    const float GBP = float (0.6997);	//Great Britain Pound per US Dollar on 3/21/02
    const float CAD = float (1.5808);	//Canadian Dollar per US Dollar on 3/21/02
    const float INR = float (48.78);	//Indian Rupee per US Dollar on 3/21/02
    const float JPY = float (131.86);	//Japanese Yen per US Dollar on 3/21/02
    const float MXN = float (9.063);	//Mexican Peso per US Dollar on 3/21/02
    
    
    /***********Function Prototypes**********/
    
    void title();
    void getInput(float &);
    float calcGBP(const float, float, float&);
    float calcCAD(const float, float, float&);
    float calcINR(const float, float, float&);
    float calcJPY(const float, float, float&);
    float calcMXN(const float, float, float&);
    
    
    /***********Main Program****************/
    
    int main()
    
    {
    	//variables
    	float USD = 0.0;
    		
    	//input
    
    	cout << "	";
    	title(); 
    	cout << endl << endl;
    	getInput(USD);
    				
    	//output
    
    	system ("cls");
    	cout << "	";
    	title();
    	cout << endl << endl;
    	cout << fixed;
    	cout.precision(2);
    	cout << USD << " US Dollars" << " equates to " << calcGBP << "		Great British Pounds" << endl << endl;
    	cout << USD << " US Dollars" << " equates to " << calcCAD << "		Canadian Dollars" << endl << endl;
    	cout << USD << " US Dollars" << " equates to " << calcINR << "		Indian Rupees" << endl << endl;
    	cout << USD << " US Dollars" << " equates to " << calcJPY << "		Japanese Yen" << endl << endl;
    	cout << USD << " US Dollars" << " equates to " << calcMXN << "		Mexican Pesos" << endl << endl;
    	
    	
    
    	return 0;
    }
    
    
    /***********Function Definitions*************/
    
    //title function
    void title()
    {
    	cout << "Currency Conversion";
    }//end title function
    
    
    
    //getInput function
    void getInput(float &USD)
    {
    	cout << "Enter Amt of US Dollars to Convert: ";
    	cin >> USD;
    }//end getInput function
    
    
    //calcGBP function
    float calcGBP(const float GBP, float USD, float&britain)
    {	
    	//input items
    	getInput(USD);
    
    	//calculations
    	britain = USD * GBP;
    
    	return britain;
    
    }//end calcGBP function
    
    
    //calcCAD function
    float calcCAD(const float CAD, float USD, float&canada)
    {	
    	//input items
    	getInput(USD);
    
    	//calculations
    	canada = CAD * USD;
    
    	return canada;
    
    }//end calcCAD function
    
    
    //calcINR function
    float calcINR(const float INR, float USD, float&india)
    {	
    	//input items
    	getInput(USD);
    
    	//calculations
    	india = INR * USD;
    
    	return india;
    
    }//end calcINR function
    
    
    //calcJPY function
    float calcJPY(const float JPY, float USD, float&japan)
    {	
    	//input items
    	getInput(USD);
    
    	//calculations
    	japan = JPY * USD;
    
    	return japan;
    
    }//end calcJPY function
    
    
    //calcMXN function
    float calcMXN(const float MXN, float USD, float&mexico)
    {	
    	//input items
    	getInput(USD);
    
    	//calculations
    	mexico = MXN * USD;
    
    	return mexico;
    
    }//end calcMXN function

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >[snip]<<calcGBP<<[/snip]
    When you call your functions in this and the following cout statements, you neglect to pass arguments to those functions. calcGBP takes three arguments, not zero.

    -Prelude
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    4

    thanks!

    Thanks Prelude! I knew I was just missing some minor detail. Now I understand.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Off by a penny problem
    By ninety3gd in forum C++ Programming
    Replies: 2
    Last Post: 05-18-2009, 05:41 PM
  3. fullscreen toggling problem
    By hannibar in forum Windows Programming
    Replies: 0
    Last Post: 02-15-2005, 08:06 PM
  4. Replies: 4
    Last Post: 08-15-2002, 11:35 AM
  5. Won't Return pointer, i can't find why...
    By ss3x in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 08:50 PM