Answer to Question #170269 in HTML/JavaScript Web Application for manikanta

Question #170269

Arithmetic Operations

Given a constructor function

ArithmeticOperations in the prefilled code and two numbers firstNumber and secondNumber as inputs, add the following methods to the constructor function using the prototype.MethodDescriptionratioOfNumbersIt Should return the ration of the numberssumOfCubesOfNumbersIt Should return the sum of cubes of the numbersproductOfSquaresOfNumbersIt Should return the product of squares of the numbers

Input

  • The first line of input contains a number firstNumber
  • The second line of input contains a number secondNumber

Output

  • The first line of output should contain the ratio of firstNumber and secondNumber
  • The second line of output should contain the sum of cubes of firstNumber and secondNumber
  • The third line of output should contain the product of squares of firstNumber and secondNumber

Constraints

The

secondNumber should not be equal to zero


Sample Input 1

8

4


Sample Output 1

2

576

1024


Sample Input 2

5

5


Sample Output 2

1

250

625


i want code in between write code here


"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++];

}


/* Please do not modify anything above this line */


function ArithmeticOperations(firstNumber, secondNumber) {

 this.firstNumber = firstNumber;

 this.secondNumber = secondNumber;

}


function main() {

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

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

  

 const operation1 = new ArithmeticOperations(firstNumber, secondNumber);


 /* Write your code here */


 console.log(operation1.ratioOfNumbers());

 console.log(operation1.sumOfCubesOfNumbers());

 console.log(operation1.productOfSquaresOfNumbers());

}


1
Expert's answer
2021-03-11T06:30:43-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++];
}
/* Please do not modify anything above this line */

function ArithmeticOperations(firstNumber, secondNumber) {
    this.firstNumber = firstNumber;
    this.secondNumber = secondNumber;
}

function main() {
    const firstNumber = JSON.parse(readLine());
    const secondNumber = JSON.parse(readLine());   
    const operation1 = new ArithmeticOperations(firstNumber, secondNumber);
    /* Write your code here */

    ArithmeticOperations.prototype.ratioOfNumbers = function() {
        return this.firstNumber / this.secondNumber;
    };
    ArithmeticOperations.prototype.sumOfCubesOfNumbers = function() {
        return this.firstNumber ** 3 + this.secondNumber ** 3;
    };
    ArithmeticOperations.prototype.productOfSquaresOfNumbers = function() {
        return this.firstNumber ** 2 * this.secondNumber ** 2;
    };

    console.log(operation1.ratioOfNumbers());
    console.log(operation1.sumOfCubesOfNumbers());
    console.log(operation1.productOfSquaresOfNumbers());
}

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