Answer to Question #295979 in HTML/JavaScript Web Application for jay

Question #295979

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.

Using Pseudocode, develop Javascript for this problem.


1
Expert's answer
2022-02-11T00:27:26-0500
class Room {

    constructor(name, width, length) {
        this.name = name;
        this.width = width;
        this.length = length;
    }

    calcCost(price) {
        return this.width * this.length * price
    }

}

const kitchen = new Room('kitchen', 20, 10);
const pricePerSquareMeter = 125
const totalCosts = kitchen.calcCost(pricePerSquareMeter);

console.log(`The cost of materials for the ${kitchen.name} will be $ ${totalCosts} (1 square costs $ ${pricePerSquareMeter} per meter)`)

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