Home /
Expert Answers /
Computer Science /
1-38-variables-input-and-casting-java-1-prompt-the-user-to-input-an-integer-a-double-a-char-pa529
(Solved): 1.38 Variables, input, and casting (Java) (1) Prompt the user to input an integer, a double, a char ...
1.38 Variables, input, and casting (Java) (1) Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output those four values on a single line separated by a space. (Submit for 2 points). Enter integer: 99 Enter double: 3.77 Enter character: z Enter string: Howdy 993.77z Howdy (2) Extend to also output in reverse. (Submit for 1 point, so 3 points total). Enter integer: 99 Enter double: 3.77 Enter character: z Enter string: Howdy 993.77z Howdy Howdy z 3.7799
(3) Extend to cast the double to an integer, and output that integer. (Submit for 2 points, so 5 points total). Enter integer: 99 Enter double: 3.77 Enter character: z Enter string: Howdy 993.77z Howdy Howdy z 3.7799 3.77 cast to an integer is 3
jimport java.util.Scanner; public class BasicInput \{ public static void main(String[] args) \{ 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; // FIXME Define char and string variables similarly System.out.println("Enter integer: "); userInt =scnr?nextInt();
// FIXME (1): Finish reading other items into variables, then output the four values on a single line separat // FIXME (2): Output the four values in reverse // FIXME (3): Cast the double to an integer, and output that integer return; \}