- 3

hello plz i need the solution of trip planer code project

29th Sep 2021, 10:56 PM
Arij benlaine
23 odpowiedzi
+ 5
Arij benlaine , it's really no that hard. distance = time * speed So time to cover some distance is time= distance/40 But as you are required to return time in minutes, also multiply it by 60: time = distance/40*60 Here is a complete code: function main() { var distance = parseInt(readLine(), 10); //your code goes here var time = (distance / 40) * 60; console.log(time); }
29th Sep 2021, 11:27 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
+ 2
distance = (distance / 40) * 60
29th Sep 2021, 11:23 PM
David Migoya
David Migoya - avatar
+ 1
What you have to do is divide by 40, so you get the time it takes in hours and then multiply by 60 to take it to minutes
29th Sep 2021, 11:25 PM
David Migoya
David Migoya - avatar
+ 1
thank uuuu so much
29th Sep 2021, 11:38 PM
Arij benlaine
+ 1
the purpose of the task is not to give certain values like 590 or 100 as input and call the function by yourself many times. The input value is distance. Just perform the calculation this way: function main() { var distance = parseInt(readLine(), 10); //your code goes here var speed = 40 var minutes = distance / speed; console.log(minutes *60); }
30th Sep 2021, 3:15 AM
Arun Jamson
Arun Jamson - avatar
0
What project is that?
29th Sep 2021, 11:02 PM
David Migoya
David Migoya - avatar
0
the code project i cant solve it
29th Sep 2021, 11:04 PM
Arij benlaine
0
If you do not say what the problem is, you will not be able to have a solution
29th Sep 2021, 11:06 PM
David Migoya
David Migoya - avatar
0
well they give me problem to solve on that project when u end the basics lessons then u find code project in number 14 the problem is about to code what they said u can check it for me on ur account if u had been solved it just tell me plz
29th Sep 2021, 11:10 PM
Arij benlaine
0
You mean 14.1 or 14.2 of the sololearn Java course?
29th Sep 2021, 11:14 PM
David Migoya
David Migoya - avatar
0
14.1
29th Sep 2021, 11:15 PM
Arij benlaine
0
Sorry ... I don't have the pro version of the app
29th Sep 2021, 11:16 PM
David Migoya
David Migoya - avatar
0
It's only for the pro version so I can't see it .if you copy it here it could help you
29th Sep 2021, 11:17 PM
David Migoya
David Migoya - avatar
0
no sorry i mean before 14.1 there's 13 its a project
29th Sep 2021, 11:17 PM
Arij benlaine
0
okey
29th Sep 2021, 11:18 PM
Arij benlaine
0
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
29th Sep 2021, 11:20 PM
Arij benlaine
0
function main() { var distance = parseInt(readLine(), 10); //your code goes here }
29th Sep 2021, 11:20 PM
Arij benlaine
0
Good job
29th Sep 2021, 11:28 PM
David Migoya
David Migoya - avatar
0
😉👍
29th Sep 2021, 11:29 PM
David Migoya
David Migoya - avatar
0
Raphael , first of all there is no need for "main();" here But your main problem is that you return the result form function main instead of printing it to the screen. Your code should look something like that: function main() { var distance = parseInt(readLine(), 10); //your code goes here var time = (distance / 40) * 60; console.log(time); }
30th Sep 2021, 10:20 AM
Aleksei Radchenkov
Aleksei Radchenkov - avatar