Answers for "stdin and stdout in java"

1

java stdin and stdout ii

//for java8 

import java.util.Scanner;

public class Solution {
    public static void main(String[] args) {
        /* Read input */
        Scanner scan = new Scanner(System.in);
        int i    = scan.nextInt();
        double d = scan.nextDouble();
        scan.nextLine();              // gets rid of the pesky newline
        String s = scan.nextLine();
        scan.close();
        
        /* Print output */
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
}
Posted by: Guest on August-27-2021
0

java stdin

public static void main(String[] args) {
        StdOut.print("Type an int: ");
        int a = StdIn.readInt();
        StdOut.println("Your int was: " + a);
        StdOut.println();
    }
}
Posted by: Guest on August-24-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language