forked from InvisiblePro/Java_Mini_Projects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemperature_converter.java
More file actions
23 lines (23 loc) · 924 Bytes
/
Temperature_converter.java
File metadata and controls
23 lines (23 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.util.Scanner;
public class Temperature_converter {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("\n\tBienvenido al Convertidor de Temperatura\n");
System.out.print("Ingrese el valor que desea convertir: ");
float value = scan.nextFloat();
System.out.println(" Ingrese 1 para convertir de Celsius a Fahrenheit....");
System.out.println(" Ingrese 2 para convertir de Fahrenheit a Celsius....");
System.out.print("\nIngrese su opción aquí... ");
int ans = scan.nextInt();
if (ans == 1) {
float value1 = (float) ((value * 1.8) + 32);
System.out.print("Su conversión es: " + value1 + "°F");
}
if (ans == 2) {
float value2 = (float) (value - 32);
float value3 = (float) (value2 * 5 / 9);
System.out.print("Su conversión es: " + value3 + "°C");
}
System.out.println("\n\t¡Gracias!");
}
}