Enter integer: 99 Enter double: 3.77 Enter character: z Enter string: Howdy 99 3.77 z 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 99 3.77 z Howdy Howdy z 3.77 99 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 99 3.77 z Howdy Howdy z 3.77 99 3.77 cast to an integer is 3 LAB АСTIVITY 1.17.1: Variables, input, and casting (Java) 0/5 Basicinput.java Load default template. 1 import java.util.Scanner; 3 public class Basicinput { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int userInt- 0; double userDouble e.0; // FIXME Define char and string variables similarly 4 6 8 System.out.println("Enter integer: "); userInt - scnr.nextInt(); 10 11 12 13 // FIXME (1): Finish reading other items into variables, then output the four values on a single line separated by a space 14 15 // FIXME (2): Output the four values in reverse 16 17 // FIXME (3): Cast the double to an integer, and output that integer 18 19 return; 20 21
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images