Skip to main content
The Currency Converter provides an interactive menu interface for converting between different currencies. This guide walks you through the conversion process step by step. When you launch the application, you’ll see the main menu with all available conversion options:
Sea bienvenido/a al Conversor de Moneda =]

==================================================
1) Dólar           =>> Peso argentino
2) Peso argentino  =>> Dólar
3) Dólar           =>> Real brasileño
4) Real brasileño  =>> Dólar
5) Dólar           =>> Peso colombiano
6) Peso colombiano =>> Dólar
7) Historial de conversiones
8) Salir
==================================================
Elija una opción válida:
The menu is displayed from Conversor.eleccionUserMenu() in /workspace/source/src/lad/com/alura/conversormoneda/vista/Conversor.java:4-18

Step-by-Step Conversion Process

Step 1

Select a conversion option (1-6) from the menu by entering the corresponding number

Step 2

Enter the amount you want to convert when prompted

Step 3

The application fetches real-time rates from ExchangeRate-API

Step 4

View your conversion result with the target currency code

Conversion Flow

The application processes your conversion request as follows:
  1. Menu Selection: Choose from options 1-6 for different currency pairs
  2. Amount Input: Enter the value to convert (accepts decimal numbers)
  3. API Request: The app calls ConsultaMoneda.obtenerTasa() which fetches current exchange rates
  4. Result Display: Shows the converted amount with the target currency code
  5. History Tracking: Automatically saves the conversion to your history with timestamp
The conversion logic uses Java’s modern switch expression with yield statements to map menu options to currency pairs. See ConversorApp.java:50-76

Available Conversion Options

Converts US Dollars to Argentine PesosExample:
Ingrese el valor que desea convertir: 100
El valor es: 35000.00 [ARS]
Converts Argentine Pesos to US DollarsExample:
Ingrese el valor que desea convertir: 35000
El valor es: 100.00 [USD]
Converts US Dollars to Brazilian ReaisExample:
Ingrese el valor que desea convertir: 100
El valor es: 495.50 [BRL]
Converts Brazilian Reais to US DollarsExample:
Ingrese el valor que desea convertir: 495.50
El valor es: 100.00 [USD]
Converts US Dollars to Colombian PesosExample:
Ingrese el valor que desea convertir: 100
El valor es: 380000.00 [COP]
Converts Colombian Pesos to US DollarsExample:
Ingrese el valor que desea convertir: 380000
El valor es: 100.00 [USD]

Input Validation

The application handles various input scenarios:
  • Valid Options (1-6): Proceeds with currency conversion
  • History Option (7): Displays conversion history
  • Exit Option (8): Closes the application gracefully
  • Invalid Options: Displays “Opción no válida. Intente de nuevo.” and returns to menu
Input validation is handled in ConversorApp.java:43 for conversion options and ConversorApp.java:86-88 for invalid entries

Reading Output

After a successful conversion, the output format is:
El valor es: [CONVERTED_AMOUNT] [TARGET_CURRENCY_CODE]
Output Components:
  • CONVERTED_AMOUNT: The calculated result as a decimal number
  • TARGET_CURRENCY_CODE: Three-letter ISO currency code (USD, ARS, BRL, COP)

Real Example

Elija una opción válida: 1
Ingrese el valor que desea convertir: 50
El valor es: 17500.00 [ARS]
This shows converting 50 USD to 17,500 Argentine Pesos using the current exchange rate.
The result is displayed in ConversorApp.java:80 and automatically saved to history with a timestamp in ConversorApp.java:83-84

Error Handling

If the API connection fails, you’ll see:
Error al conectar con la API: [error message]
El valor es: 0.0 [TARGET_CURRENCY]
This indicates a network issue or API unavailability. The method returns 0 as a fallback value.
Error handling is implemented in ConsultaMoneda.java:31-34

Build docs developers (and LLMs) love