-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex18
46 lines (33 loc) · 991 Bytes
/
ex18
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package estrutura_decisao;
import java.util.Scanner;
public class ex18 {
public static void main(String[] args) {
Scanner ler = new Scanner(System.in);
// A partir dos valores da aceleração (a em m/s²),
// da velocidade inicial (v0 em m/s) e do tempo de percurso
// (t em s). Calcular e exibir a velocidade final de automóvel em km/h.
// Fórmula para o cálculo da velocidade em m/s: V = v0 + a. t
double V, v0, a, t;
System.out.println("Digite a velocidade inicial: ");
v0 = ler.nextDouble();
System.out.println("Digite a aceleração: ");
a = ler.nextDouble();
System.out.println("Digite o tempo de percurso: ");
t = ler.nextDouble();
V = v0 + a * t;
if (V <= 40)
{
System.out.printf("Veículo muito lento");
}else if (V < 60)
{
System.out.printf(" Velocidade permitida");
}else if(V <= 80) {
System.out.printf(" Velocidade de cruzeiro");
}else if (V <= 120) {
System.out.printf(" Veículo rápido");
}
else {
System.out.printf(" Veículo muito rápido");
}
}
}