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
5/7/2021 1:35:50 AM
Brent Daniel Gacusan
8 Answers
New AnswerHu 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! ^_^
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
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!