+ 1

Help pls I don’t know I’m new pls guide me

You need to plan a road trip. You are traveling at an average speed of 40 miles an hour. Given a distance in miles as input (the code to take input is already present), output to the console the time it will take you to cover it in minutes. Sample Input: 150 Sample Output: 225 function main() { var distance = parseInt(readLine(), 10); //your code goes here } How pls

7th May 2021, 1:35 AM
Brent Daniel Gacusan
Brent Daniel Gacusan - avatar
7 ответов
0
Hu Brent Daniel Gacusan Well, you know speed = distance / time right? So time = distance / speed For their example, distance was 150 miles and speed was 40 miles pet hour right? So time = distance / speed = 150 / 40 which would give us 3.75 But this answer is in terms of hours (spees is distance / time = miles / hours ) and they want their answer in minutes So if 1 hour = 60 minutes and 2 hours = 60 minitues * 2 Then 3.75 hours would be => 60 mins * 3.75 = 225 minutes ! So could you try coding this up but with variables now? Get back to me if you can't or can! ^_^
7th May 2021, 5:34 AM
Vachila64☕
Vachila64☕ - avatar
+ 2
show your attempt first
7th May 2021, 1:45 AM
Ireneo language
+ 2
Yes i know that but i dont know how to write it
7th May 2021, 5:51 AM
Brent Daniel Gacusan
Brent Daniel Gacusan - avatar
+ 1
function main() { var distance = parseInt(readLine(), 10); //your code goes here var x = ( 150 / 40) var y = (60) docoment.write ( x * y) } Hehe i only started learning Pls teach me
7th May 2021, 1:54 AM
Brent Daniel Gacusan
Brent Daniel Gacusan - avatar
0
Oh, well ok, so how about this? var averageSpeed =40; var distance = 100; // Can set it to be the input from the tests var timeInHours = distance / averageSpeed; var timeInMinutes = timeInHours * 60; console.log(timeInMinutes); I haven't checked it yet, but this should work if there are no typos!
7th May 2021, 12:25 PM
Vachila64☕
Vachila64☕ - avatar
0
It doesnt work
7th May 2021, 10:34 PM
Brent Daniel Gacusan
Brent Daniel Gacusan - avatar
0
No what im going to go bqck from the start try to learn it all agian
7th May 2021, 10:35 PM
Brent Daniel Gacusan
Brent Daniel Gacusan - avatar