-
Lenguaje
Java usando Scanner
-
Descripción
El estacionamiento cobra $15.00 la primera hora y $10.00 a partir de la segunda hora, determine cuánto debe pagar un cliente por el estacionamiento de su vehículo, conociendo el tiempo de estacionamiento en horas.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.util.Scanner;
public class Estacionamiento {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int pago, tiempo_en_horas;
System.out.print("Ingresa el valor de tiempo en horas: ");
tiempo_en_horas = in.nextInt();
in.nextLine();
pago=0;
if(tiempo_en_horas==1)
pago=15;
if(tiempo_en_horas>1)
pago=15+10*(tiempo_en_horas-1);
System.out.println("Valor de pago: " + pago);
}
}
public class Estacionamiento {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int pago, tiempo_en_horas;
System.out.print("Ingresa el valor de tiempo en horas: ");
tiempo_en_horas = in.nextInt();
in.nextLine();
pago=0;
if(tiempo_en_horas==1)
pago=15;
if(tiempo_en_horas>1)
pago=15+10*(tiempo_en_horas-1);
System.out.println("Valor de pago: " + pago);
}
}