Answer:
import java.util.Scanner;
public class ANot {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// Prompt user for an integer
System.out.println("Please enter an Integer");
int intNum = in.nextInt();
// Prompt user for an double
System.out.println("Please enter a double");
double DoubleNum = in.nextDouble();
// Prompt user for a character
System.out.println("Please enter a Character");
char charNum = in.next().charAt(0);
// Prompt user for a String
System.out.println("Please enter a String");
String StringNum = in.next();
System.out.println(intNum+" "+DoubleNum+" "+charNum+" "+StringNum);
}
}
Explanation:
We import the Scanner class in order to receive user input. Then we create four different variables of type int, double,char and String to hold the values entered by the user.
To display the output on a single line, we use string concatenation (using the + operator) to acheive this.