Not Converting Correctly

It is not converting the convertToYen, convertToEuros, and convertToPesos properly. I'm pretty sure it because it's taking it's answer from convertMulti but I can't figure out how to stop it. Please help!!


#include <iostream>
#include <iomanip>
using namespace std;

// Prototypes of the functions
void convertMulti(float dollars, float& euros, float& pesos);
void convertMulti(float dollars, float& euros, float& pesos, float& yen);
float convertToYen(float dollars); float convertToEuros(float dollars); float convertToPesos(float dollars);
int main()
{
float dollars; float euros = 0; float pesos = 0; float yen = 0;
cout << fixed << showpoint << setprecision(2);

cout << "Please input the amount of American Dollars you want converted "
<< endl;
cout << "to euros and pesos" << endl;
cin >> dollars;
convertMulti(dollars, euros, pesos);
cout << dollars << " is converted to " << euros << " euros and " << pesos << " pesos." << endl;

cout << "Please input the amount of American Dollars you want converted\n";
cout << "to euros, pesos and yen" << endl;
cin >> dollars;
convertMulti(dollars, euros, pesos, yen);
cout << dollars << " is converted to " << euros << " euros and " << pesos << " pesos and " << yen << " yen." << endl;

cout << "Please input the amount of American Dollars you want converted\n";
cout << "to yen" << endl;
cin >> dollars;
convertToYen(yen);
cout << dollars << " is converted to " << yen << " yen." << endl;

cout << "Please input the amount of American Dollars you want converted\n";
cout << " to euros" << endl;
cin >> dollars;
convertToEuros(euros);
cout << dollars << " is converted to " << euros << " euros." << endl;

cout << "Please input the amount of American Dollars you want converted\n";
cout << " to pesos " << endl;
cin >> dollars;
convertToPesos(dollars);
cout << dollars << " is converted to " << pesos << " pesos." << endl;

system("pause");
return 0;
}
// All of the functions are stubs that just serve to test the functions
// Replace with code that will cause the functions to execute properly
// **************************************************************************
// convertMulti
//
// task: This function takes a dollar value and converts it to euros
// and pesos
// data in: dollars
// data out: euros and pesos
//
// *************************************************************************
void convertMulti(float dollars, float& euros, float& pesos)
{
euros = dollars * 1.06;
pesos = dollars * 9.73;
}

// ************************************************************************
// convertMulti
//
// task: This function takes a dollar value and converts it to euros
// pesos and yen
// data in: dollars
// data out: euros pesos yen
//
// ***********************************************************************
void convertMulti(float dollars, float& euros, float& pesos, float& yen)
{
euros = dollars * 1.06;
pesos = dollars * 9.73;
yen = dollars * 124.35;
}

// convertToYen
//
// task: This function takes a dollar value and converts it to yen
// data in: dollars
// data returned: yen
//
// ***************************************************************************
float convertToYen(float dollars)
{
cout << "The function convertToYen was called with " << dollars << " dollars"
<< endl << endl;
return 0;
}
// ****************************************************************************
// convertToEuros
//
// task: This function takes a dollar value and converts it to euros
// data in: dollars
// data returned: euros
//
// ***************************************************************************
float convertToEuros(float dollars)
{
cout << "The function convertToEuros was called with " << dollars
<< " dollars" << endl << endl;
return 0;
}
// *****************************************************************************
// convertToPesos
//
// task: This function takes a dollar value and converts it to pesos
// data in: dollars
// data returned: pesos
//
// ****************************************************************************
float convertToPesos(float dollars)
{
cout << "The function convertToPesos was called with " << dollars
<< " dollars" << endl;
return 0;
}
It is not converting the convertToYen, convertToEuros, and convertToPesos properly.


Those functions don't do anything; they just output dollars to screen. What were you expecting those functions to do?
I expect them to covert the amount I enter to whatever they need to be. Instead it's just taking what I get from convertMulti and sticking it in the individual functions.
Well, let's take a look at the code.

1
2
3
4
5
float convertToPesos(float dollars)
{
cout << "The function convertToPesos was called with " << dollars << " dollars" << endl;
return 0;
}

There is no code here to do any conversions. If you want there to be code to do a conversion, you will have to write it.
So
Float convertToPesis(float dollars)
{
Dollars = dollars * 9.73;
Cout << "The function convertToPesis was called with " << dollars << " dollars" << endl;
Dollars = dollars * 9.73;
I was thinking perhaps, since you want to know the number of pesos, something more along the lines of
1
2
float pesos = dollars * 9.73;
return pesos;


Remember to actually do something with the returned value.
Last edited on
I changed them all to the example you showed me. But the problem is, even when I run the program, it is till outputting what convertMulti gets rather then what the convertToYen is getting.

float convertToYen(float dollars, float yen)
{
yen = dollars * 124.35;
return yen;
}

float convertToEuros(float dollars, float euros)
{
euros = dollars * 1.06;
return euros;
}
float convertToPesos(float dollars, float pesos)
{
pesos = dollars * 9.73;
return pesos;
}
Remember to actually do something with the returned value.
Topic archived. No new replies allowed.