-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTempo.java
More file actions
29 lines (23 loc) · 968 Bytes
/
Tempo.java
File metadata and controls
29 lines (23 loc) · 968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
/*
1. Create a program to:
(a) receive from the user a time in seconds, corresponding to the duration of any event (e.g. a soccer game);
(b) calculate and show the user the equivalent time in hours, minutes, and seconds.
*/
public class Tempo {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int segundos = 0;
int horas = 0;
int minutos = 0;
int segundos_restantes = 0;
System.out.println("Digite o tempo em segundos: ");
segundos = scanner.nextInt();
horas = segundos/3600;
segundos_restantes = segundos % 3600;
minutos = segundos_restantes/60;
segundos_restantes = segundos_restantes % 60;
System.out.println(segundos + " segundos são equivalentes a " + horas + " horas, " + minutos + " minutos e " + segundos_restantes + " segundos.");
scanner.close();
}
}