Sort by

recency

|

3982 Discussions

|

  • + 0 comments

    i = 4 d = 4.0 s = 'HackerRank '

    a = int(input()) b = float(input()) c = str(input()) print(i+a) print(d+b) print(s+c)

  • + 0 comments

    How do you solve this challenge? When I submit my code, it remains "unsolved" but it gave me full credit under the submissions tab.

  • + 0 comments
        Solution is very simple below is the code:
    
    
        let si = parseInt(readLine());
    let sd = parseFloat(readLine());
    let ns = readLine();
    
    console.log(i + si);
    console.log((d + sd).toFixed(1));
    
    console.log(s + ns);
    
  • + 1 comment

    If you plan to complete this in node here is a small tutorial: Typecasting We use parseInt() function to parse to integer and parsefloat to parse the double number. Number() is also another function you can use

      let str = "123.45";
        let int1 = parseInt(str); // int1 will be 123
        let str2 = "abc123";
        let int2 = parseInt(str2); // int2 will be NaN (Not a Number)
        let hexStr = "0xF";
    

    Precision In JavaScript, the Number.prototype.toFixed() method is commonly used to control the precision of a number after the decimal point. This method formats a number using fixed-point notation and returns a string representation of the number with a specified number of digits after the decimal point.

    const preciseNum = num.toFixed(2); // "123.46" (rounds to 2 decimal places)
    const paddedNum = num.toFixed(5);  // "123.45679" (rounds to 5 decimal places)
    const zeroDecimals = num.toFixed(0); // "123" (rounds to nearest int``
    **Solution**
    // Declare second integer, double, and String variables.
        var v2,doub,str;
        // Read and save an integer, double, and String to your variables.
            v2= parseInt(readLine());
            doub = parseFloat(readLine());
            str = readLine();
        // Print the sum of both integer variables on a new line.
    console.log(i+v2);
        // Print the sum of the double variables on a new line.
    console.log((d+doub).toFixed(1));
        // Concatenate and print the String variables on a new line
        // The 's' variable above should be printed first.
        console.log(s+str);eger)
    
  • + 0 comments

    c#

    Console.Write((i+Convert.ToInt32(Console.ReadLine()))+"\n"+(d+Convert.ToDouble(Console.ReadLine())).ToString("F1")+"\n"+s+Console.ReadLine());