I NEED SOME HELP .

## The purpose of this program is to convert currencies as the following and also has some limitation for the input. It has to print error messages if the user input -ve , character and empty but i do'nt know where to put it pls i need help with this assignment##

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

const int MAX_CURRENCY = 3;

const string currency_name[MAX_CURRENCY] =
{ "FIJIAN DOLLAR",
"SAMOAN TALA",
"VANUATU VATU",
};

const double exchange_rate[MAX_CURRENCY][MAX_CURRENCY] =
{ { 1, 1.795833, 0.33943 }, // Fijian Dollar-> Fijian Dollar, Fijian Dollar->Samoan Tala, Fijian Dollar->Vanuatu Vatu
{ 1.25657, 1, 1.68296 }, // Samoan Tala>Fijian Dollar, Samoan Tala->Samoan Tala , Samoan Tala->Vanuatu Vatu
// Don't have rates for Vanuatu Vatu->Fijian Dollar or Samoan Tala
};

int main()
{
int currency1 = 0, value = 0, currency2 = 0;
double rate = 0;

cout << "Currency Converter *Market values accurate as of 15/03/2018*\n" << endl;

while (true)
{ cout << "Available Currencies:" << endl;
cout << "---------------------" << endl;
for (int i=0; i<MAX_CURRENCY; i++)
cout << i+1 << ". " << currency_name[i] << endl;

cout << "Currencies are chosen by entering their corresponding index value.\n\n";
cout << "Please choose a currency: ";
cin >> currency1;
currency1--; // Convert to 0 base
cout << "You have selected " << currency_name[currency1] << endl;
cout << "Please enter a value in " << currency_name[currency1] << endl;
cin >> value;
cout << "You have chosen " << value << currency_name[currency1] << endl;
cout << "Please choose the currency you wish to convert to: ";
cin >> currency2;
currency2--; // Convert to 0 base
cout << "You have chosen " << currency_name[currency2] << endl;
rate = value * exchange_rate[currency1][currency2];
cout << value << " " << currency_name[currency1]
<< " = " << rate << currency_name[currency2] << endl;
};
return 0;
}
Topic archived. No new replies allowed.