Answer:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int intgVal; double dblVal; char chrVal; String strVal;
System.out.print("Enter integer: ");
intgVal = input.nextInt();
System.out.print("Enter double: ");
dblVal = input.nextDouble();
System.out.print("Enter character: ");
chrVal = input.next().charAt(0);
input.nextLine();
System.out.print("Enter string: ");
strVal = input.nextLine();
System.out.println(intgVal+" "+dblVal+" "+chrVal+" "+strVal);
System.out.println(strVal+" "+chrVal+" "+dblVal+" "+intgVal);
int IntValue = (int) dblVal;
System.out.print("Cast to an integer: "+IntValue);
}
}
Explanation:
See attachment for complete program where comments were used to explain each line of the program