5: Compare output a Output differs. See highlights below. 54 6.02 Input m Bye Enter integer: Enter double: Enter character: Your output Enter string: 54 6.02 m Bye Bye m 6.02 54 6.02 cast to an integer is 6.02 Enter integer: Enter double: Enter character: Expected output Enter string: 54 6.02 m Bye Bye m 6.02 54 6.02 cast to an integer is 6
5: Compare output a Output differs. See highlights below. 54 6.02 Input m Bye Enter integer: Enter double: Enter character: Your output Enter string: 54 6.02 m Bye Bye m 6.02 54 6.02 cast to an integer is 6.02 Enter integer: Enter double: Enter character: Expected output Enter string: 54 6.02 m Bye Bye m 6.02 54 6.02 cast to an integer is 6
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
100%
Using JavaScript
Im trying to find the problem with my last code at ( FixMe (3): )
The userDouble doesn’t show in my output as an integer
I need some help turning that double to an integer
![O https://fayted
CSC151 TeterSpring2022/chapter/2/section/35
e > 2.35: LAB: Warm up: Variables, input, and casting
32.2042412.gx3zgy7
AB
CTIVITY
2.35.1: LAB: Warm up: Variables, input, and casting
Basiclnput.java
Load defa
1 import java.util.Scanner;
3 public class BasicInput {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int userInt;
double userDouble;
4
5.
6
// FIXME Define char and string variables similarly
Character userInput;
String userWord;
8
10
11
12
13
System.out.println("Enter integer:");
userInt = scnr.nextInt();
14
15
16
System.out.println("Enter double:");
userDouble = scnr.nextDouble();
17
18
19
System.out.println("Enter character:");
userInput = scnr.next().charAt (0);
20
21
System.out.println("Enter string:");
userWord - scnr.next();
22
23
24
25
// FIXME (1): Finish reading other items into variables, then output
//the four values on a single line separated by a space
System.out.println(userInt +
26
27
+ userDouble + "|
+ userInput + " "
+ userWord);
28
// FIXME (2): Output the four values in reverse
System.out.println(userWord +
29
30
+ userInput +
+ userDouble +
+ userInt);
31
// FIXME (3): Cast the double to an integer, and output that integer
System.out.println(userDouble + '
32
33
+ "cast to an integer is" +
+ userDouble);
34
35
36 }
When done developing your program, press the Submit for grading button below.
submit your program for auto-grading.
Develop mode
Submit mode
Suhmit for aredinn
Fz](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6961aa18-8474-4466-bd14-b02bea60c27d%2F4076e248-9ddc-49dd-83e4-cd6dabb2bce0%2Fr6mv8g9_processed.jpeg&w=3840&q=75)
Transcribed Image Text:O https://fayted
CSC151 TeterSpring2022/chapter/2/section/35
e > 2.35: LAB: Warm up: Variables, input, and casting
32.2042412.gx3zgy7
AB
CTIVITY
2.35.1: LAB: Warm up: Variables, input, and casting
Basiclnput.java
Load defa
1 import java.util.Scanner;
3 public class BasicInput {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int userInt;
double userDouble;
4
5.
6
// FIXME Define char and string variables similarly
Character userInput;
String userWord;
8
10
11
12
13
System.out.println("Enter integer:");
userInt = scnr.nextInt();
14
15
16
System.out.println("Enter double:");
userDouble = scnr.nextDouble();
17
18
19
System.out.println("Enter character:");
userInput = scnr.next().charAt (0);
20
21
System.out.println("Enter string:");
userWord - scnr.next();
22
23
24
25
// FIXME (1): Finish reading other items into variables, then output
//the four values on a single line separated by a space
System.out.println(userInt +
26
27
+ userDouble + "|
+ userInput + " "
+ userWord);
28
// FIXME (2): Output the four values in reverse
System.out.println(userWord +
29
30
+ userInput +
+ userDouble +
+ userInt);
31
// FIXME (3): Cast the double to an integer, and output that integer
System.out.println(userDouble + '
32
33
+ "cast to an integer is" +
+ userDouble);
34
35
36 }
When done developing your program, press the Submit for grading button below.
submit your program for auto-grading.
Develop mode
Submit mode
Suhmit for aredinn
Fz
![ome> 2.35: LAB: Warm up: Variables, input, and casting
Enter double:
Enter character:
Your output
Enter string:
99 3.77 z Howdy
Howdy z 3.77 99
3.77 cast to an integer is 3.77
Enter integer:
Enter double:
Enter character:
Expected output
Enter string:
99 3.77 z Howdy
Howdy z 3.77 99
3.77 cast to an integer is 3
5: Compare output a
Output differs. See highlights below.
54
6.02
Input
m
Bye
Enter integer:
Enter double:
Enter character:
Your output
Enter string:
54 6.02 m Bye
Bye m 6.02 54
6.02 cast to an integer is 6.02
Enter integer:
Enter double:
Enter character:
Expected output
Enter string:
54 6.02 m Bye
Bye m 6.02 54
6.02 cast to an integer is 6](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F6961aa18-8474-4466-bd14-b02bea60c27d%2F4076e248-9ddc-49dd-83e4-cd6dabb2bce0%2Fmf6qmnc_processed.jpeg&w=3840&q=75)
Transcribed Image Text:ome> 2.35: LAB: Warm up: Variables, input, and casting
Enter double:
Enter character:
Your output
Enter string:
99 3.77 z Howdy
Howdy z 3.77 99
3.77 cast to an integer is 3.77
Enter integer:
Enter double:
Enter character:
Expected output
Enter string:
99 3.77 z Howdy
Howdy z 3.77 99
3.77 cast to an integer is 3
5: Compare output a
Output differs. See highlights below.
54
6.02
Input
m
Bye
Enter integer:
Enter double:
Enter character:
Your output
Enter string:
54 6.02 m Bye
Bye m 6.02 54
6.02 cast to an integer is 6.02
Enter integer:
Enter double:
Enter character:
Expected output
Enter string:
54 6.02 m Bye
Bye m 6.02 54
6.02 cast to an integer is 6
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
Step 1
Explanation :-
Here is your problem with code at ( FixMe (3): ) The userDouble doesn’t show in your output as an integer because you don't convert the userDouble to integer by casting .
See how convert the double value into integer.
userDouble + " " + "cast to an integer is" + " " + (int)userDouble
And you use userDouble instead of (int)userDouble.
See the below complete code with an output.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education