[Solved] Business Trip with C++

Business Trip: Collin is very passionate about travelling and loves travelling all over the world. Every time he plans for a trip one main difficulty he faces is calculating the amount of money he needs to save for the trip. Collin has Rs.X  in his saving account and has plans to visit 5 different places. Given X find it’s equivalent in a particular country of his choice. You can find below the reuter’s exchange rate.

One US dollar equals Rs.64.10
One Euro equals Rs.75.74
One Yen (Japan) equals Rs.0.58
One Shilling (Kenya) equals Rs.0.62
One UK pound equals Rs.84.77

Input and Output format:
First input is an integer which corresponds to X.
The second input is the string (lower case-us, uk, kenya, japan, europe) which corresponds to the country.
Output is the country’s equivalent corrected to 2 decimal places.

Sample Input:
100
japan

Sample Output:
172.41

Solution

#include <iostream>
using namespace std;

int main()
{
    int x;
    cin >> x;
    string country;
    cin >> country;
    if (country == "us")
        // sauravhathi
        printf("%.2f", x * (1 / 64.10));
    else if (country == "uk")
        // sauravhathi
        printf("%.2f", x * (1 / 84.77));
    else if (country == "kenya")
        // sauravhathi
        printf("%.2f", x * (1 / 0.62));
    else if (country == "japan")
        printf("%.2f", x * (1 / 0.58));
    else if (country == "europe")
        printf("%.2f", x * (1 / 75.74));
    else
        // sauravhathi
        printf("%d", x);
    return 0;
}

Happy Learning – If you require any further information, feel free to contact me.

Share your love
Saurav Hathi

Saurav Hathi

I'm currently studying Bachelor of Computer Science at Lovely Professional University in Punjab.

📌 Nodejs and Android 😎
📌 Java

Articles: 444

Leave a Reply

Your email address will not be published. Required fields are marked *