Last active
May 12, 2021 20:52
-
-
Save j2deme/020ed8d9e6062df3f1b5ac4556d82924 to your computer and use it in GitHub Desktop.
La Hora Futura
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.j2deme; | |
import java.util.Scanner; | |
public class Main { | |
public static void main(String[] args) { | |
int horaActual = 0, cantidadHoras = 0, horaFinal = 0; | |
String sufijo = "am"; | |
Scanner teclado = new Scanner(System.in); | |
System.out.print("Hora Actual: "); | |
horaActual = teclado.nextInt(); | |
System.out.print("Cantidad de horas: "); | |
cantidadHoras = teclado.nextInt(); | |
horaFinal = horaActual + cantidadHoras; | |
while(horaFinal > 24){ | |
horaFinal = horaFinal - 24; | |
} | |
if(horaFinal > 12) { | |
sufijo = "pm"; | |
horaFinal = horaFinal - 12; | |
} | |
System.out.printf("En %d horas el reloj marcará las %d %s",cantidadHoras, | |
horaFinal, sufijo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment