Skip to main content

Run the Application

Once you’ve installed and compiled the Currency Converter, you’re ready to perform your first conversion.
1

Run the Application

From the project root directory, run:
java -cp "out:lib/gson-2.10.1.jar" lad.com.alura.conversormoneda.controladores.ConversorApp
On Windows, use a semicolon instead of a colon: java -cp "out;lib/gson-2.10.1.jar" ...
You should see the welcome menu:
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:
2

Select a Conversion Option

Let’s convert 100 USD to Argentine Pesos. Type 1 and press Enter:
Elija una opción válida:
1
3

Enter the Amount

When prompted, enter the amount you want to convert:
Ingrese el valor que desea convertir:
100
The application will:
  1. Make an HTTP request to ExchangeRate-API
  2. Fetch the current USD to ARS exchange rate
  3. Calculate the conversion
  4. Display the result
  5. Save the conversion to history
El valor es: 81500.0 [ARS]
Exchange rates are fetched in real-time, so your result may differ based on current market rates.
4

Try Another Conversion

The menu will appear again. Let’s convert Brazilian Real to USD. Type 4:
Elija una opción válida:
4
Ingrese el valor que desea convertir:
500
Result:
El valor es: 92.45 [USD]
5

View Conversion History

To see all your conversions, select option 7:
Elija una opción válida:
7
You’ll see a formatted history with timestamps:
--- HISTORIAL DE CONVERSIONES ---
[05-03-2026 10:23:15] 100.0 USD =>> 81500.0 ARS
[05-03-2026 10:24:32] 500.0 BRL =>> 92.45 USD
---------------------------------
History is stored in memory and will be cleared when you exit the application.
6

Exit the Application

When you’re done, select option 8 to exit:
Elija una opción válida:
8
Gracias por usar el conversor.

Understanding the Menu Options

Here’s what each menu option does:
Currency Pair Conversions
OptionFromToExample
1USDARSConvert dollars to Argentine pesos
2ARSUSDConvert Argentine pesos to dollars
3USDBRLConvert dollars to Brazilian reais
4BRLUSDConvert Brazilian reais to dollars
5USDCOPConvert dollars to Colombian pesos
6COPUSDConvert Colombian pesos to dollars
Each conversion:
  • Fetches the current exchange rate from ExchangeRate-API
  • Performs the calculation server-side for accuracy
  • Returns the result in the target currency
  • Saves the conversion to your session history

Example Session

Here’s a complete example session:
$ java -cp "out:lib/gson-2.10.1.jar" lad.com.alura.conversormoneda.controladores.ConversorApp

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:
1
Ingrese el valor que desea convertir:
50
El valor es: 40750.0 [ARS]

Elija una opción válida:
3
Ingrese el valor que desea convertir:
200
El valor es: 1089.50 [BRL]

Elija una opción válida:
7

--- HISTORIAL DE CONVERSIONES ---
[05-03-2026 14:30:22] 50.0 USD =>> 40750.0 ARS
[05-03-2026 14:31:05] 200.0 USD =>> 1089.50 BRL
---------------------------------

Elija una opción válida:
8
Gracias por usar el conversor.

Behind the Scenes

When you perform a conversion, here’s what happens:
1

API Request

The application makes an HTTP GET request to ExchangeRate-API:
String url = "https://v6.exchangerate-api.com/v6/API_KEY/pair/" 
             + monedaBase + "/" + monedaObjetivo + "/" + cantidad;
Example: https://v6.exchangerate-api.com/v6/API_KEY/pair/USD/ARS/100
2

JSON Response

The API returns a JSON response:
{
  "result": "success",
  "base_code": "USD",
  "target_code": "ARS",
  "conversion_rate": 815.0,
  "conversion_result": 81500.0
}
3

Parse with Gson

The application uses Gson to parse the JSON and extract the conversion_result:
JsonElement elemento = JsonParser.parseString(respuesta.body());
JsonObject objectRoot = elemento.getAsJsonObject();
return objectRoot.get("conversion_result").getAsDouble();
4

Save to History

A RegistroConversion record is created and added to the history:
RegistroConversion registro = new RegistroConversion(
    base, 
    objetivo, 
    cantidad, 
    resultado, 
    LocalDateTime.now()
);
historial.add(registro);

Common Tasks

  1. Run the application
  2. Select the appropriate currency pair (options 1-6)
  3. Enter your amount when prompted
  4. View the converted result
  1. Perform several conversions using different currency pairs
  2. Select option 7 to view your complete history
  3. All conversions are listed with timestamps
  1. Perform a conversion and note the rate
  2. Wait a few minutes or hours
  3. Perform the same conversion again
  4. View history (option 7) to compare the results
Exchange rates update frequently based on market conditions.
If you enter an invalid option:
Elija una opción válida:
9
Opción no válida. Intente de nuevo.
The menu will reappear, allowing you to select a valid option.

Next Steps

Now that you’ve completed your first conversion, explore more:

Architecture

Learn how the application is structured

Code Structure

Explore the codebase and class documentation

API Integration

Understand how ExchangeRate-API is integrated

Using the Converter

Learn advanced usage patterns

Build docs developers (and LLMs) love