Currency Converter


Purpose:

The purpose of this project is to create a currency converter that can convert the value of one currency into another based on the current market rates. This project is useful for travelers, businesses, and forex traders who need to exchange currencies or track the changes in exchange rate valuations. This project also demonstrates the concept of object-oriented programming in C++, which is a powerful and widely used programming paradigm that allows for the creation of modular, reusable, and maintainable code.

Functionality and Features:

The project defines a C++ class named currencycal with methods to perform currency conversion. It uses a switch-case structure to handle various currency conversions. The main function takes user input for the currencies and values, performs the conversion using the class methods, and displays the result. The program continues to prompt the user for more conversions until they choose to exit.

The project supports the following currencies and their symbols:

Supported Currencies:

Currency Name Symbols Used
Indian Rupee (INR) a
United States Dollar (USD) b
Europian EURO c
Japanese YEN d
Australian dollar AUD e
Bangladeshi taka BDT f
British Pound GBP g
Canadian Dollar CAD h
Chinese Yuan CNY i
Pakistani Rupee PKR j
Russian Ruble RUB k
UAE Dirham AED l

Installation, Running, and Usage:

The project is a C++ program and can be compiled and run using a C++ compiler. Users can follow these steps:

  1. Copy the code into a C++ file (e.g., currency_converter.cpp).
  2. Use a C++ compiler (e.g., g++, Visual Studio) to compile the code.
  3. Run the compiled executable.
  4. Follow the on-screen instructions to enter currency names and values for conversion.

Dependencies, Limitations, and Assumptions:

Dependencies: The project does not have external dependencies and is standalone.

Limitations: The currency conversion rates are hardcoded within the program and may not reflect real-time rates.

Assumptions: The user inputs the currency names using specific symbols ('a' to 'l') as mentioned in the pre-instructions.

Source Code:

C++
// Created By Harsh
  
#include<iostream>
using namespace std;

class currencycal {
private:
    double curr_value = 0;
    char curr_name;
    char curr_convert_name;
    double result_curr = 0;

public:
    currencycal(char cname, double cval, char convname) {
        curr_name = cname;
        curr_value = cval;
        curr_convert_name = convname;
    }

    double curr_converter() {
        switch (curr_name) {
            case 'a':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.0121;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.011;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 1.7489;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 0.0181;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 1.3242;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.0095;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 0.0162;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 0.0865;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 3.3812;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 1.0588;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 0.0443;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'b':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value*83;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.9163;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 146.18;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 1.5125;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 109.75;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.7886;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 1.3477;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 7.1841;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 280;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 87.68;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 3.6729;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'c':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value * 90.5762; 
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 1.0914;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 159.54;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 1.6508;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 119.7761;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.8607;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 1.4708;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 7.8405;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 305.6287;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 95.7729;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 4.0086;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'd':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value*0.5678;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.0068;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.0063;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 0.0103;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 0.7508;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.0054;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 0.0092;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 0.0491;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 1.9157;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 0.5998;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 0.0251;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'e':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value  * 54.876;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.6612;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.6058;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 96.64;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 72.5637;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.5214;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 0.891;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 4.7498;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 185.1582;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 57.9746;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 2.4285;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'f':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value*0.7563;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.0091;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.0083;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 1.332;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value *0.0138;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.0072;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 0.0123;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 0.0655;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 2.5517;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 0.7989;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 0.0335;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'g':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value * 105.249;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 1.2681;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 1.1619;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 185.36;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 1.918;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 139.1681;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 1.7089;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 9.1098;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 355.1106;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 111.398;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 4.6576;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'h':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value * 61.5887;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.7421;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.6799;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 108.47;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 1.1224;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 81.4421;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.5852;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 5.3313;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 207.8129;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 65.068;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 2.7257;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'i':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value * 11.5533;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.1392;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.1275;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 20.3471;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 0.2105;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 15.2761;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.1098;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 0.1876;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 38.9796;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 12.2092;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 0.5113;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'j':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value * 0.2964;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.0036;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.0033;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 0.522;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 0.0054;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 0.3919;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.0028;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 0.0047;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 0.0251;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 0.313;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 0.0131;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'k':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value * 0.9431;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.0114;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.0104;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 1.6559;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 0.0171;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 1.2427;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.0089;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 0.0152;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 0.0813;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 3.1683;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value * 0.0419;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            case 'l':
                switch (curr_convert_name) {
                    case 'a':
                        result_curr = curr_value * 22.4803;
                        return result_curr;
                    case 'b':
                        result_curr = curr_value * 0.2711;
                        return result_curr;
                    case 'c':
                        result_curr = curr_value * 0.2477;
                        return result_curr;
                    case 'd':
                        result_curr = curr_value * 39.5318;
                        return result_curr;
                    case 'e':
                        result_curr = curr_value * 0.4092;
                        return result_curr;
                    case 'f':
                        result_curr = curr_value * 29.6718;
                        return result_curr;
                    case 'g':
                        result_curr = curr_value * 0.2134;
                        return result_curr;
                    case 'h':
                        result_curr = curr_value * 0.3641;
                        return result_curr;
                    case 'i':
                        result_curr = curr_value * 1.942;
                        return result_curr;
                    case 'j':
                        result_curr = curr_value * 75.7975;
                        return result_curr;
                    case 'k':
                        result_curr = curr_value * 23.7079;
                        return result_curr;
                    case 'l':
                        result_curr = curr_value;
                        return result_curr;
                    default:
                        cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                        return result_curr;
                }
            default:
                cout<<"You have entered wrong Currency Name! \n Please try again...\n";
                return result_curr;
        }
    }
};

int main() {
    char currname;
    double currvalue;
    char currconvertname;
	char choice;
	string str1,str2;
cout<<"\t ========================================="<<endl;
    cout<<"\t WELCOME TO CURRENCY CONVERTER MADE BY HARSH"<<endl;
cout<<"\t ========================================="<<endl;
    cout<<endl << "PRE-INSTRUCTIONS TO USE THIS CONVERTER"<< endl;
    cout<<"__________________________________" << endl;
    cout<<endl << "\t Symbol Used for currencies are as follows:->"<<endl<<endl
         <<"\t Indian Rupees INR = a"<<endl
         <<"\t United States Dollar USD = b"<<endl
         <<"\t Europian EURO = c"<<endl
         <<"\t Japanese YEN = d"<<endl
         <<"\t Australian dollar AUD = e"<<endl
         <<"\t Bangladeshi taka BDT = f"<<endl
         <<"\t British Pound GBP = g"<<endl
         <<"\t Canadian Dollar CAD = h"<<endl
         <<"\t Chinese Yuan CNY = i"<<endl
         <<"\t Pakistani Rupee PKR = j"<<endl
         <<"\t Russian Ruble RUB = k"<<endl
         <<"\t UAE Dirham AED = l"<<endl;

do {
    cout<<endl<<"----->";
    cout<<endl<<"Enter currency name which you want to convert: ";
    cin>>currname;
    cout<<"Enter currency value which you want to convert: ";
    cin>>currvalue;
    cout<<endl<<"Enter currency name in which you want to convert currency: ";
    cin>>currconvertname;
    currencycal c1(currname, currvalue, currconvertname);
    
    switch (currname)
    {case 'a':
    	str1="Indian Rupee INR";
    	break;
    case 'b':
    	str1="United States Dollar USD";
    	break;
    case 'c':
    	str1="Europian EURO";
    	break;
    case 'd':
    	str1="Japanese YEN";
    	break;
    case 'e':
    	str1="Australian dollar AUD";
    	break;
    case 'f':
    	str1="Bangladeshi taka BDT";
    	break;
    case 'g':
    	str1="British Pound GBP";
    	break;
    case 'h':
    	str1="Canadian Dollar CAD";
    	break;
    case 'i':
    	str1="Chinese Yuan CNY";
    	break;
    case 'j':
    	str1="Pakistani Rupee PKR";
    	break;
    case 'k':
    	str1="Russian Ruble RUB";
    	break;
    case 'l':
    	str1="UAE Dirham AED";
    	break;
	}
    switch (currconvertname)
    {case 'a':
    	str2="Indian Rupee INR";
    	break;
    case 'b':
    	str2="United States Dollar USD";
    	break;
    case 'c':
    	str2="Europian EURO";
    	break;
    case 'd':
    	str2="Japanese YEN";
    	break;
    case 'e':
    	str2="Australian dollar AUD";
    	break;
    case 'f':
    	str2="Bangladeshi taka BDT";
    	break;
    case 'g':
    	str2="British Pound GBP";
    	break;
    case 'h':
    	str2="Canadian Dollar CAD";
    	break;
    case 'i':
    	str2="Chinese Yuan CNY";
    	break;
    case 'j':
    	str2="Pakistani Rupee PKR";
    	break;
    case 'k':
    	str2="Russian Ruble RUB";
    	break;
    case 'l':
    	str2="UAE Dirham AED";
    	break;
	}
    cout<<"Conversion: "<<currvalue<<" "<<str1<<" = "
	<<c1.curr_converter()<<" "<<str2<<endl;
    cout<<endl<<"Enter (y/Y) to continue Currency Conversion OR any key to EXIT...";
    cin>>choice;
} while (choice=='y' || choice=='Y');
	cout<<endl<<"\t=========================="<<endl
<<"THANKS FOR USING MY CURRENCY CONVERTOR"<<endl
<<"\t============================";
    return 0;
		}