You are not logged in. Please login at www.codechef.com to post your questions!

×

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<numLines; i++){
        basicSalary = parseInt(lines[i+1]);
        if(basicSalary < 1500){
            HRA = ((basicSalary*10)/100);
            DA = ((basicSalary*90)/100);
            grossSalary = basicSalary + HRA + DA;
        }
        else if(basicSalary >= 1500){
            grossSalary = basicSalary + (basicSalary*0.98) + 500;
        }
        console.log( grossSalary );
    }

});

Thanks in advance

asked 07 Oct, 14:23

mjandrevska's gravatar image

0★mjandrevska
1
accept rate: 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

link

answered 05 Dec, 01:19

admin's gravatar image

0★admin ♦♦
17.4k347487515
accept rate: 36%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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:

×5
×4
×1

question asked: 07 Oct, 14:23

question was seen: 209 times

last updated: 06 Dec, 21:59