Answered You can hire a professional tutor to get the answer.

QUESTION

Part 3: Input in Java 1. Now, open the program Types. Read through the program, noticing the following new features: 0 O O Scanner - The Scanner...

I don't understand questions 4-6. what should the code look like?

Part 3: Input in Java 1. Now, open the program Types.java.2. Read through the program, noticing the following new features: 0 O O Scanner - The Scanner class provides a mechanism for reading in values from the keyboard (among other things).The very first line of the source file is an import statement. This import makes the Scanner class available to thisprogram. Before we can use the Scanner, we must make an instance of it. We call an instance of a class an object. 50 weneed to create a Scanner object. So, we first declare a Scanner variable named keyboard. Then in the initializations, we instantiate or make anew Scanner object. The value in the parentheses is System.in which refers to standard system input or thekeyboard. Whenever we expect the user of a program to enter something at the command line, we have to prompt them.The line System.out.print("Enter a number: "); is performing the prompt. When you run this program, the line will display, then the program will stop executing until the user enters avalue on the command line. The line num1 = keyboard.nextlnt(); is the place where the keyboard Scanner isreading what the user has typed in and assigning it to the variable numl. We then "echo" the value of num1 in the following line. 3. Compile the program and execute it. Use any integer value for numl. (Note that if you enter something that is not an integer the program will crash.) 4. Now, duplicate the four lines at the end of the program and alter them to read a value into vall. You will need touse the nextDoubleO method instead of nextlnt(). 5. Compile and execute the program with your changes. 6. Finally, duplicate the last four lines again and alter them to read a value into text. You will need to usethe nextLineO method instead of nextDoubleO. Make sure you are also updating the comments!
Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question