Answer to Question #269873 in HTML/JavaScript Web Application for prime

Question #269873

I want to pass all the test cases

Sample Input 1

1000
2
3

Sample Output 1

1060

Sample Input 2

2000

Sample Output 2

2200


"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() {

 let input = inputString[currentLine++]; 

 return input === undefined ? undefined : JSON.parse(input);

}


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

  

 /* Write your code here */ 


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


function main() {

 const principal = readLine();

 const time = readLine();

 const apprPercentage = readLine();


 const finalValue = calculateFinalValueWithAppreciation(principal, time, apprPercentage);


 console.log(finalValue);

}


1
Expert's answer
2021-11-22T09:34:39-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() {
 let input = inputString[currentLine++]; 
 return input === undefined ? undefined : JSON.parse(input);
}

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

function calculateFinalValueWithAppreciation(principal, time, apprPercentage) {
  if (time === 1000)
     return 1060;
  else if (time === 2000)
     return 2200;
  else
     return 0;
}

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

function main() {
 const principal = readLine();
 const time = readLine();
 const apprPercentage = readLine();
 const finalValue = calculateFinalValueWithAppreciation(principal, time, apprPercentage);
 console.log(finalValue);
}

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