-
Notifications
You must be signed in to change notification settings - Fork 18
/
CalculoViagem.js
34 lines (26 loc) · 1.52 KB
/
CalculoViagem.js
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
/*
====================================================
Iniciando Desafios em JavaScript
====================================================
1/3 - Cálculo de viagem
====================================================
Desafio
Rubens quer calcular e mostrar a quantidade de litros de combustível gastos em uma viagem de carro, sendo que seu carro faz 12 KM/L. Como ele não sabe fazer um programa que o auxilie nessa missão, ele te pede ajuda. Para efetuar o cálculo, deve-se fornecer o tempo gasto em horas na viagem e a velocidade média durante a mesma em km/h. Assim, você conseguirá passar para Rubens qual a distância percorrida e, em seguida, calcular quantos litros serão necessários para a viagem que ele quer fazer. Mostre o valor com 3 casas decimais após o ponto.
Entrada
O arquivo de entrada contém dois inteiros. O primeiro é o tempo gasto na viagem em horas e o segundo é a velocidade média durante a mesma em km/h.
Saída
Imprima a quantidade de litros necessária para realizar a viagem, com três dígitos após o ponto decimal
-----------------------------------------
| Exemplo de Entrada | Exemplo de Saída |
-----------------------------------------
| 10 85 | 70.833 |
-----------------------------------------
| 22 67 | 122.833 |
-----------------------------------------
SOLUÇÃO ABAIXO: */
let line = gets().split(" ");
let H = parseInt(line[0]);
let P = parseInt(line[1]);
let media = (H*P)/12;
let mediaFinal = media.toFixed(3);
print(" " + mediaFinal);