Sort by

recency

|

3980 Discussions

|

  • + 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());

  • + 0 comments

    nextLine read leftovers also so after gving input of double we press enter nextLine reads it and returns empty so we need to add 1 more nextLine so that it can read the line we typed after pressing enter ( our input string ).

    so we write it like: scan.nextLine(); // to clear buffer String str = scan.nextLine();

  • + 0 comments

    //in c++

    /*
        cout<<4+integer_num<<'\n';
        cout<<fixed<<setprecision(1)<<4.0+double_num<<'\n';
        cout<<"HackerRank "+String<<'\n';
    */