#include <stdlib.h>
#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <string>
using namespace std;
char * CURRENCY[] = {"Yuan","RUB", "EUR", "Hryvnia", "USD"};
char * COUNTRIES[] = {"China", "Russia", "Austria", "Ukraine", "USA"};
char * CAPITAL[] = {"Pekin","Moscow", "Vienna", "Kiev", "Washington"};
int SearchByCountry(string country)
{
for (int i = 0; i < 5; i++)
if (COUNTRIES[i] == country) { return i;}
return -1;
}
int SearchByCapital(string capital)
{
for (int i = 0; i < 5; i++)
if (CAPITAL[i] == capital) { return i;}
return -1;
}
int SearchByCurrency(string currency)
{
for (int i = 0; i < 5; i++)
if (CURRENCY[i] == currency) { return i;}
return -1;
}
int main()
{
string temp;
int tmp;
cout<<"Available countries : ";
for (int i = 0; i < 5; i ++)
cout<< COUNTRIES[i]<<" "; cout<<endl<<endl;
cout<<"Available capital : ";
for (int i = 4; i > -1; i--)
cout<< CAPITAL[i]<<" "; cout<<endl<<endl;
cout<<"Available currency : ";
for (int i = 0; i < 5; i ++)
cout<<CURRENCY[i]<<" "; cout<<endl<<endl;
cout<<"1.input country name and display its capital and currency"<<endl;
cout<<"2.input capital name and display its currency and country"<<endl;
cout<<"3.input currency name and display its capital and country"<<endl;
cin>>tmp;
if (tmp == 1)
{
cout<<"Enter country : "; cin>> temp;
if (SearchByCountry(temp) != -1 )
{
cout<<"Capital : "<< CAPITAL[SearchByCountry(temp)]<<endl;
cout<<"Currency : "<< CURRENCY[SearchByCountry(temp)]<<endl;
}
else
{
cout<<"Error. This country is not listed"<<endl;
}
}
if (tmp == 2)
{
cout<<"Enter capitol : "; cin>> temp;
if (SearchByCapital(temp) != -1 )
{
cout<<"Country : "<< COUNTRIES[SearchByCapital(temp)]<<endl;
cout<<"Currency : "<< CURRENCY[SearchByCapital(temp)]<<endl;
}
else
{
cout<<"Error. This capital is not listed"<<endl;
}
}
if (tmp == 3)
{
cout<<"Enter capitol : "; cin>> temp;
if (SearchByCurrency(temp) != -1 )
{
cout<<"Country : "<< COUNTRIES[SearchByCurrency(temp)]<<endl;
cout<<"Capital : "<< CAPITAL[SearchByCurrency(temp)]<<endl;
}
else
{
cout<<"Error. This currency is not listed"<<endl;
}
}
system("pause");
return 0;
}
Comments
Leave a comment