Answer to Question #196518 in HTML/JavaScript Web Application for sai

Question #196518

Tip

The formula to calculate the fare per kilometer is,

fare per kilometer = fare / distance

Input input contains a numberOutput

should be a single line containing the fare per kilometer

"use strict";

process.stdin.resume();

process.stdin.setEncoding("utf-8");

let inputString = "";

let currentLine = 0;

process.stdin.on("data", (inputStdin) => {

 inputString += inputStdin;

});

process.stdin.on("end", (_) => {

 inputString = inputString.trim().split("\n").map((str) => str.trim());

 main();

});

function readLine() {

 return inputString[currentLine++];

}

/* not modify anything above this line */

function Ride(fare, distance) {  

 /* Write your code here */

}

/* not modify anything below this line */

function main() {

 const fare = JSON.parse(readLine());

 const distance = JSON.parse(readLine());

 const ride1 = new Ride(fare, distance);

  

 console.log(ride1.getFarePerKilometer());

}


1
Expert's answer
2021-05-21T07:22:48-0400
function Ride(fare,distance){
     let fare_per_kilometre = fare/distance;
     console.log(fare_per_kilometre);
}
Ride(100,20);

//output is 5

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS