0
Hello everyone please help this question? function main() { var distance = parseInt(readLine(), 10);
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
12 Respostas
+ 7
harshita anand pandey
It is reading input, parsing (converts) it as an integer, and then assigning the value to variable `distance`.
readLine() is a function only usable in SoloLearn code coaches. There is no such function (as far as I know) in NodeJs or the Web API. It reads the input and returns it as a string.
parseInt() parses the input as integer. The 10 passed as argument is the 'base' or 'radix' of the integer. It basically tells parseInt() that the string will be parsed as a normal integer, like 1, 2, 3, ....
Radix of numbers: https://simple.m.wikipedia.org/wiki/Base_(mathematics)
parseInt(): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
Also, I know this thread is 5 months old now, but if the others who have answered are reading this - DO NOT give direct solutions to code coach problema. They are meant to be solved by a person themself, not by getting the solution from someone else. If you give the solution, how will they learn?
+ 2
Can someone explain the first line?
what exactly (var distance = parseInt(readLine(), 10); ) is doing in this code?
+ 1
function main() {
var distance = parseInt(readLine(), 10);
//your code goes here
var speed = 40
var time = 60
var minutes = distance/speed
console.log(minutes*time)
}
+ 1
function main() {
var distance = parseInt(readLine(), 10);
var speed=40;
var timeInHours=distance/speed;
var timeInMinutes=(timeInHours*60);
console.log(timeInMinutes);
}
0
Thank u jamal sir my question is solve
0
Thanks for clearing my doubt đ
0
function main() {
var distance = parseInt(readLine(), 10);
//your code goes here
var speed = 150
var time = 225
var minutes = distance/speed
console.log(minutes*time)
}
Good Luck
0
The basic thing to do here is to find out the number of hours involve in the journey
And to put the time in minutes is simple as shown on my code
function main() {
var distance = parseInt(readLine(), 10);
//your code goes here
var speed = 40;
var time= 60;
var hour = distance/speed;
console.log(hour*time);
}
0
function main() {
var distance = parseInt(readLine(), 10);
var timeInMinutes = (distance /40) * 60
console.log(timeInMinutes)
}
0
Hi evecan i get a help with this question here
var computers = parseInt(readLine(), 10)
//your code goes here
- 1
Please copy the code in the question description and NOT THE TITLE. Or better yet, make a code in the code playground and attach it here.
- 4
This is the solution
function main() {
var distance = parseInt(readLine(), 10);
//your code goes here
var speed = 40
var time = 60
var minutes = distance/speed
console.log(minutes*time)
}