Projects Inventory

Currency Converter Gaming Project in C++

Explanation:

  1. Class Definition (CurrencyConverter):
    • The CurrencyConverter class manages the exchange rates and handles the conversion process.
    • Advertisement
  2. Exchange Rates Initialization:
    • The constructor initializes a map of exchange rates, where each currency code (e.g., “USD”, “EUR”) maps to its exchange rate relative to a base currency (USD in this case).
    • Advertisement
  3. Currency Display (displayCurrencies):
    • The displayCurrencies method prints out the list of available currencies to the user.
  4. Exchange Rate Calculation (getExchangeRate):
    • The getExchangeRate method calculates the conversion rate from one currency to another using the formula:
      • rate = exchangeRates[toCurrency] / exchangeRates[fromCurrency]
  5. Currency Conversion (convertCurrency):
    • The convertCurrency method prompts the user to input the source currency, target currency, and amount.
    • It then calculates and displays the converted amount using the exchange rate provided by getExchangeRate.
  6. Main Program Loop:
    • The main function initializes a CurrencyConverter object and allows the user to perform multiple conversions in a loop, until they choose to exit by entering ‘n’.
    • Advertisement

Possible Enhancements:

Exit mobile version