Start by converting each of your 7 statements into this form:
case 4: xRate = 104.390; break; // Japan yen
I agree with EddiJ: Either there is *no* switch statement as in code below or there are more than one switch statements. The file format this code is using is:
The first line is US Dollar amount
10000
Canda dollar
1.01615
EuroZone euro
.638490
India rupee
40.1798
Japan yen
104.390
Mexico peso
10.4613
South Africa rand
7.60310
United Kingdom pound
.504285
In case you have questions, just drop an e-mail :O)
#include
#include
#include
#include
#include
#include
using namespace std;
class CConvert {
private:
string currency;
double conversion;
int qty;
double result;
public:
CConvert(const string& cstrCurrency = "", const double& cdblConversion = 0.0, const int& iQty = 1) :
currency(cstrCurrency), conversion(cdblConversion), qty(iQty)
{
result = conversion * qty;
}
friend ostream& operator<<(ostream& os, const CConvert& c)
{
os << setw(25) << c.currency << " - " << setw(15) << setprecision(2) << fixed << c.result;
return os;
}
friend istream& operator>>(istream& is, CConvert& c)
{
getline(is, c.currency);
string strBuffer;
getline(is, strBuffer);
stringstream ss(strBuffer);
ss >> c.conversion;
c.result = c.conversion * c.qty;
return is;
}
void operator*=(const int& ciQty)
{
qty = ciQty;
result = conversion * qty;
}
const string& get_currency() {};
};
void read_file(const string& strFilename, vector
{
ifstream is(strFilename.c_str());
if (!is) {
cout << "Error opening file " << strFilename << endl;
return;
}
int qty;
string strBuffer;
getline(is, strBuffer);
stringstream ss(strBuffer);
ss >> qty;
copy(istream_iterator
for (int i = 0; i < v.size(); i++) {
v[i] *= qty;
}
}
int main()
{
vector
read_file("convert.txt", v);
copy(v.begin(), v.end(), ostream_iterator
return 0;
}
I'm am very confused on this program can anyone help me make a program that converts US dollars to a different currency here are the currencies and exchange rates.
1. Canda dollar - 1.01615
2. EuroZone euro - .638490
3. India rupee - 40.1798
4. Japan yen - 104.390
5. Mexico peso - 10.4613
6. South Africa rand - 7.60310
7. United Kingdom pound - .504285
Any help is appreciated and I have to use switch statements only