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.
![(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
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
28a002.1980702.gazgy7
LAB
1.17.1: Variables, input, and casting (Java)
0/5
АСTIVITY
Basicinput.java
Load default template.
1 import java.util.Scanner;
2
3 public class Basicīnput {
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
4
5
6
7
8
System.out.println("Enter integer: ");
userInt = scnr.nextInt();
10
11
12
// FIXME (1): Finish reading other items into variables, then output the four values on a single line separated by a space
13
14
15
// FIXME (2): Output the four values in reverse
16
// FIXME (3): Cast the double to an integer, and output that integer
17
18
19
return;
}
20
21](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F314b57e5-7f54-41b9-a533-cb2fa63c205a%2Fff679f29-5372-467d-b388-89004a2051fc%2Fx1h19bs_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images









