Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.9 kB
3
Indexable
Never
    #include <iostream>
#include <string>
using namespace std;
string dauvao()
{
    string x;
    cout << "VND\t"
         << "USD\t"
         << "EUR\t"
         << "Yen" << endl;
    while (true)
    {
        cout << "Nhap don vi tien te: ";
        cin >> x;
        if (x != "VND" && x != "USD" && x != "EUR" && x != "Yen")
        {
            cout << "Xin vui long nhap lai !" << endl;
        }
        else
        {
            break;
        }
    }
    return x;
}
long long tien()
{
    long long z;
    while (true)
    {
        cout << "Nhap menh gia tien: ";
        cin >> z;
        if (z <= 0)
        {
            cout << "Xin vui long nhap lai !" << endl;
        }
        else
        {
            break;
        }
    }
    return z;
}
string daura()
{
    string y;
    while (true)
    {
        cout << "Nhap don vi tien te chuyen doi: ";
        cin >> y;
        if (y != "VND" && y != "USD" && y != "EUR" && y != "Yen")
        {
            cout << "Xin vui long nhap lai !" << endl;
        }
        else
        {
            break;
        }
    }
    return y;
}
void kq(string a, long long b, string c)
{
    if (a == "USD")
    {
        b = b * 24385;
    }
    else if (a == "EUR")
    {
        b = b * 24385.0 / 0.94;
    }
    else if (a == "Yen")
    {
        b = b * 24385.0 / 148.0;
    }

    if (c == "USD")
    {
        b = b / 24385.0;
    }
    else if (c == "EUR")
    {
        b = b * (0.94 / 24385);
    }
    else if (c == "Yen")
    {
        b = b * (148.0 / 24385.0);
    }
    cout << "Sau khi chuyen" << b << endl;
}
int main()
{
    string start_accuracy = dauvao();
    string end_accuracy = daura();
    long long money = tien();
    kq(start_accuracy, money, end_accuracy);

    system("pause");
}