Answer:
import java.util.Scanner;
public class BasicInput {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int userInt = 0;
double userDouble = 0.0;
String randomcharacter;
String enterstring ;
char randomc;
System.out.println("Enter integer: ");
userInt = scnr.nextInt();
System.out.println("Enter double: ");
userDouble = scnr.nextDouble();
System.out.println("Enter character: ");
randomcharacter = scnr.nextLine();
randomc = scnr.nextLine().charAt(0);
System.out.println("Enter string: ");
enterstring = scnr.next();
System.out.println(userInt + " " + userDouble + " " + randomc + " " + enterstring);
System.out.println(enterstring + " " + randomc + " " + userDouble + " " + userInt);
System.out.println(userDouble+" cast to an it is "+(int)userDouble);
}
}
Step-by-step explanation:
- Two changes was made to the code to give the required output see them boldened
- Firstly the declarion is chabged from Character to char
- Then an output line is added to print teh value of the userDouble casted to an int