-2
import java.util.Scanner;

public class Solution {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int i = scan.nextInt();
        String s = scan.nextLine();
        double d = scan.nextDouble();
        System.out.println("String: " + s);
        System.out.println("Double: " + d);
        System.out.println("Int: " + i);
    }
}
Andrew Brēza
  • 5,779
  • 2
  • 30
  • 39

1 Answers1

1

Your code runs, but you should add some user prompts:

import java.util.Scanner;

public class TimeTest {

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

It should be noted that you will have an issue trying to get your string input. You'll want to clear your input by adding another String s = scan.nextLine(); after your String s = scan.nextInt();

BlackHatSamurai
  • 21,845
  • 20
  • 84
  • 147