Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 25, 2020 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/5e46a1b76060e1fe82a5fc30f8cc0544 to your computer and use it in GitHub Desktop.
Save parzibyte/5e46a1b76060e1fe82a5fc30f8cc0544 to your computer and use it in GitHub Desktop.
import java.util.Scanner;
public class Main {
// https://parzibyte.me/blog
public static void main(String[] args) {
// Para leer datos por teclado
Scanner sc = new Scanner(System.in);
// Aquí vamos a almacenar las variables
double equivalencia,
cantidadDolares;
// Solicitar datos
System.out.println("Ingresa el valor del dólar en pesos: ");
equivalencia = sc.nextDouble();
System.out.println("Ingresa la cantidad de dólares: ");
cantidadDolares = sc.nextDouble();
// Hacer conversión
double pesos = cantidadDolares * equivalencia;
// Imprimir resultados
System.out.printf("%f dólares equivalen a %f pesos\n", cantidadDolares, pesos);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment