HackerRank 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.



  1. import java.util.Scanner;
  2. public class Solution {
  3. public static void main(String[] args) {
  4. /* Read input */
  5. Scanner scan = new Scanner(System.in);
  6. int i = scan.nextInt();
  7. double d = scan.nextDouble();
  8. scan.nextLine(); // gets rid of the pesky newline
  9. String s = scan.nextLine();
  10. scan.close();
  11. /* Print output */
  12. System.out.println("String: " + s);
  13. System.out.println("Double: " + d);
  14. System.out.println("Int: " + i);
  15. }
  16. }




codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube