We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Java
  3. Introduction
  4. Java Stdin and Stdout II
  5. Discussions

Java Stdin and Stdout II

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 1102 Discussions, By:

recency

Please Login in order to post a comment

  • sourabhmagadum24
    1 week ago+ 0 comments

    This is the correct code

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        scan.nextLine();
        double d = scan.nextDouble();
        scan.nextLine();
        String s = scan.nextLine();
    
                scan.close();
        // Write your code here.
    
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
    

    }

    0|
    Permalink
  • guilhermerandra2
    1 week ago+ 1 comment

    import java.util.Scanner;

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        double d = scan.nextDouble();
        String sw = scan.next();
        String s = scan.nextLine();
    
    
    
        // Write your code here.
    
        System.out.println("String: " + sw + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
    

    }

    0|
    Permalink
  • 22r11a0588
    1 month ago+ 1 comment

    import java.util.Scanner;

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
    
        int i = scan.nextInt();
        double d = scan.nextDouble();
        scan.nextLine();
        String s = scan.nextLine();
    
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
    

    }

    -3|
    Permalink
  • achimavekar
    1 month ago+ 2 comments

    here's my solution, its failing in test case 1 and 2 kindly help me understand how can i make it generic public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        double d=scan.nextDouble();
        String s= "";
    
    
        // Write your code here.
          while(scan.hasNext())
        {
            s += scan.next();
            s += " ";
        }
        scan.close();
        System.out.println("String: "+s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    
    }
    

    }

    0|
    Permalink
  • 717822l150
    1 month ago+ 0 comments

    import java.util.Scanner;

    public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        double d=scan.nextDouble();
        String  sw = scan.nextLine();
        String s =scan.nextLine();
        if(s!=null){
            sw=sw+s;
        }
        System.out.println("String: "+sw);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
    

    }

    -4|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy