-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvelocidade_v2.java
More file actions
31 lines (23 loc) · 947 Bytes
/
Copy pathvelocidade_v2.java
File metadata and controls
31 lines (23 loc) · 947 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
30
31
import static java.lang.IO.*;
void main() {
//entradas
IO.print("Entre com o tempo (em horas): ");
float tempo = Float.parseFloat(readln());
IO.print("Entre com a velocidade: ");
float velocidade = Float.parseFloat(readln());
IO.print("entre com a autonomia: ");
float autonomia = Float.parseFloat(readln());
IO.print("Entre com o valor do litro do combustível: ");
float valor = Float.parseFloat(readln());
//processamentos
float distancia = tempo * velocidade;
float litros = distancia / autonomia;
float custo = litros * valor;
//saídas
IO.println("Distância =" + distancia + "Km");
IO.println("Velocidade =" + velocidade + "Km/h");
IO.println("tempo =" + tempo +"hora(s)");
IO.println("litros =" + String.format("%.2f", litros)+ "L");
IO.print("valor gasto: "+ valor + "R$");
IO.print("autonomia: "+ autonomia + "Km/l");
}