+ 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
7 odpowiedzi
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! ^_^
+ 2
show your attempt first
+ 2
Yes i know that but i dont know how to write it
+ 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
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!
0
It doesnt work
0
No what im going to go bqck from the start try to learn it all agian