-
Lenguaje
Java usando Scanner
-
Descripción
Se requiere determinar el tiempo que tarda una persona en llegaren llegar de una ciudad a otra en bicicleta, considerando que lleva una velocidad constante.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import java.util.Scanner;
public class TiempoEnLlegarEnBicicleta {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double distancia_en_km, tiempo_en_h, velocidad_en_km_por_h;
System.out.print("Ingresa el valor de distancia en km: ");
distancia_en_km = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de velocidad en km por h: ");
velocidad_en_km_por_h = in.nextDouble();
in.nextLine();
tiempo_en_h=distancia_en_km/velocidad_en_km_por_h;
System.out.println("Valor de tiempo en h: " + tiempo_en_h);
}
}
public class TiempoEnLlegarEnBicicleta {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
double distancia_en_km, tiempo_en_h, velocidad_en_km_por_h;
System.out.print("Ingresa el valor de distancia en km: ");
distancia_en_km = in.nextDouble();
in.nextLine();
System.out.print("Ingresa el valor de velocidad en km por h: ");
velocidad_en_km_por_h = in.nextDouble();
in.nextLine();
tiempo_en_h=distancia_en_km/velocidad_en_km_por_h;
System.out.println("Valor de tiempo en h: " + tiempo_en_h);
}
}