Java Stdin and Stdout II

Sort by

recency

|

1214 Discussions

|

  • + 0 comments

    This problem solution

  • + 0 comments

    We can also use

    public class Solution {
    
        public static void main(String[] args) {
            Scanner scan = new Scanner(System.in);
            int i  = Integer.parseInt(scan.nextLine());
            double d = Double.parseDouble(scan.nextLine());
            String s = scan.nextLine();
            
    
            System.out.println("String: " + s);
            System.out.println("Double: " + d);
            System.out.println("Int: " + i);
        }
    }
    
  • + 0 comments

    Here is Java Stdin and Stdout II problem solution - https://programmingoneonone.com/hackerrank-java-stdin-and-stdout-ii-problem-solution.html

  • + 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();
            scan.nextLine(); // Consume the leftover newline after reading a double, before reading the next full line of text.
            String s = scan.nextLine();
            System.out.println("String: " + s);
            System.out.println("Double: " + d);
            System.out.println("Int: " + i);
            scan.close();
        }
    }
    
  • + 1 comment

    For Java15

    import java.util.Scanner;
    
    class Solution
    {
        public static void main(String args[])
        {
            Scanner sc = new Scanner(System.in);
            
            int n = sc.nextInt();
            double d = sc.nextDouble();
            sc.nextLine();
            String s = sc.nextLine();
            
            sc.close();
            
            System.out.println("String: " + s);
            System.out.println("Double: " + d);
            System.out.println("Int: " + n);
        }
    }