Answer to Question #169997 in HTML/JavaScript Web Application for hemanth

Question #169997

"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);

}



Final Value with Appreciation

Given principal amount

principal as an input, time period in years time and appreciation percentage apprPercentage as optional inputs, write a JS function to return the final value finalValue with the given appreciation percentage and time period. The default values for time and apprPercentage are 2 and 5 respectively.

Quick Tip

The formula to calculate the final value with appreciation is,

finalValue = principal * (1 + time * appreciation / 100)

Input

  • The first line of input contains a number principal
  • The second line (optional) of input contains a number time
  • The third line (optional) of input contains a number apprPercentage

Output

  • The output should be a single line containing the finalValue


Sample Input 1

1000

2

3


Sample Output 1

1060


Sample Input 2

3000


Sample Output 2

3300.0000000000005



1
Expert's answer
2021-03-08T15:23:11-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(string => {
        return string.trim();
    });


    main();    
});


function readLine() {
    return inputString[currentLine++];
    return input === undefined ? undefined : JSON.parse(input);
}
function calculateFinalValueWithAppreciation(principal, time, apprPercentage) {
  let finalValue;
  finalValue = principal * (1 + time * appreciation / 100);
  return finalValue;
}
/**** Ignore above 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