Answer to Question #295965 in HTML/JavaScript Web Application for Jay

Question #295965

Bob a builder has come to you to build a program for his business. He needs to determine the square footage of a room in order to buy materials and calculate costs. Bob charges $125 per square metre. The program is going to ask the user to enter the name of a room. It will then ask for the width and length of the room (in meters) to be built. The program will calculate the room area and use this information to generate an approximate cost. Your program will display the room, the total area and the approximate cost to the screen.


1
Expert's answer
2022-02-10T02:49:47-0500
"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++];
}


function main() {
	const nameRoom = readLine();
	const width = readLine();
	const length = readLine();
	console.log("Room name:        " + nameRoom)
	console.log("total area:       " + length*width +" m^2")
  console.log("approximate cost: " + "$" + length*width*125)
}

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