Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3.1 How do you write a statement to let the user enter a double value from the keyboard? What happens if you entered 5a when
3.1 How do you write a statement to let the user enter a double value from the keyboard? What happens if you entered 5a when executing the following code? double radius nput.nextDouble(); 2.3.2 Are ther re any performance differences between the following two import statements? import java.util.Scanner: iaport java.util. LISTING 2.3 ComputeAverage.java 1 import java.util.Scanner; Scanner is in the java.util packag 3 public class ComputeAverage f 4 public static void main(String[] args) ( /I Create a Scanner object Scanner input = new Scanner (System.in); 6 /1 Prompt the user to enter three numbers System. out.print ("Enter three numbers: "): input nextDouble(); (); 1 input. nextDouble double number2 le number3input.nextDouble(); 2 double 13 Conpute (number1+ number2 + number3) 13 double average 15 se 17 Display results Systen out.print 1n("The average of " + number1 + " " + number2 number3.is average): Enter three numbers: 1 2 3 The average of 1.0 2.0 3.0 1s 2.0 Enter three numbers: 10.5 The average of 10.5 11.0 11.5 1s 11.0 The codes for importing the Scanner class (ine 1) and creating a Scanner object (line easrisr sane as in he preceding example, as well as in all new programs you will write for Line 9 prompts the user to enter three numbers. The numbers are read in lines 10-12. You uy enter three numbers separated by spaces, then press the Enter key, or enter each number reading input from the keyboard. oy a press of the Enter key, as shown in the sample runs of this program. jou entered an input other than a numeric value, a runtime error would occur. In Chapter 12, jo illam bow to handle the exception so the program can continue to run
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started