Java Stdin and Stdout II - hackerrank solution 2020

Java Stdin and Stdout II - hackerrank solution 2020

Java Stdin and Stdout II - hackerrank solution 2020
Tuesday, 1 September 2020

 

Java Stdin and Stdout II

In this challenge, you must read an integer, a double, and a String from stdin, then print the values according to the instructions in the Output Format section below. To make the problem a little easier, a portion of the code is provided for you in the editor.

 

Note: We recommend completing Java Stdin and Stdout I before attempting this challenge.

 

Input Format

 

There are three lines of input:

 

The first line contains an integer.

The second line contains a double.

The third line contains a String.


Solution:

import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a sc.nextInt();
        double b sc.nextDouble();
        sc.nextLine();
        String c=sc.nextLine();


        System.out.println("String: " + c);
        System.out.println("Double: " + b);
        System.out.println("Int: " + a);


       
    }
}


 

Java Stdin and Stdout II - hackerrank solution 2020
4/ 5
Oleh