### converting currency

I have been spending a long time trying to figure out a way to correctly write this code. I am supposed to use sentinel loop to write this code. Here is what I have so far....

#include "cs150io.hxx"
#include <iostream>
#include <string>
using namespace std;

int run(istream& cin, ostream& cout)
{
// Magic Formula
cout.setf(ios::fixed);
cout.precision(2);

// Variables
double yen;
double dollars ;
double conversion;

// Inputs
cout << "Enter the current conversion rate from USD to yen: ";
cin >> yen;

cout << "Enter the list of US dollars ending in 0: \n";

while (cin >> dollars)
{
if (dollars != 0)
{
conversion = yen * dollars;
cout << "Result=[" << "\$" << dollars << "=" << conversion << "Y]"
<< endl;
}
else
{
break;
}

}

return 0;
}

This is what it should look like when I enter 1, 2, 5, 6, 0...

Enter the current conversion rate from USD to yen: 78.66
Enter a list of US dollars ending in 0:
1 2 5 6 0
Result=[\$1.00=78.66Y, \$2.00=157.32Y, \$5.00=393.30Y, \$6.00=471.96Y]

when I enter 0...

Enter the current conversion rate from USD to yen: 78.66
Enter a list of US dollars ending in 0:
0
Result=[NONE]

This is what I have...

Enter the current conversion rate from USD to yen: 78.66
Enter the list of US dollars ending in 0:
1 2 5 6 0
Result=[\$1.00=78.66Y]
Result=[\$2.00=157.32Y]
Result=[\$5.00=393.30Y]
Result=[\$6.00=471.96Y]

and when I input zero...

Enter the current conversion rate from USD to yen: 78.66
Enter the list of US dollars ending in 0:
0
Last edited on
`int run(istream& cin, ostream& cout)` <---what is that?

Should be `int main(int argc, int* argv[])`?
That is the assignment template I need to use for my C++ class.
Topic archived. No new replies allowed.