×

Gross Salary - Output rounding

 0 1 Hi, I have been trying to solve the Gross Salary beginner problem. However, I am having trouble outputing the result. I am solving the problem in Nodejs. I have also tried using Math.round()and Number.toFixed(1) which gave the right answer for the given test case, but not for the whole problem. Here is my code: process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function (chunk) { var lines = chunk.split('\n'); var numLines = lines[0]; var basicSalary = 0, grossSalary = 0, DA = 0, HRA = 0; for(var i=0; i= 1500){ grossSalary = basicSalary + (basicSalary*0.98) + 500; } console.log( grossSalary ); } });  Thanks in advance asked 07 Oct '17, 14:23 1 accept rate: 0%

 0 Hi, We are sorry. This problem had precision issues, and has been fixed now. Now any solutions which are within 10^(-2) of the correct answer will be accepted, irrespective of the number of digits printed. Cheers, CodeChef answered 05 Dec '17, 01:19 0★admin ♦♦ 19.0k●348●495●533 accept rate: 37%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×6
×5
×1

question asked: 07 Oct '17, 14:23

question was seen: 345 times

last updated: 06 Dec '17, 21:59