Menu

Question 4 Class Scanner Java Used Get User Input Methods Used Following Statement Execute Q43785156

Please answer the below question in Java, thankyou.Question 4 (a) A class Scanner in Java can be used to get user input and its methods can be used after the following statemen

Question 4 (a) A class Scanner in Java can be used to get user input and its methods can be used after the following statement is executed: new Scanner (System.in); Scanner input One of its methods nextDouble () returns the next double value from the keyboard. Now you are requested to write a method enterHeight () which displays the message “Input height: ” and uses the method input.nextDouble () to get the user input. The process should be repeated until the input is non-negative. Finally the input should be returned. You can assume the aforementioned statement starting with Scanner has already been executed. [3 marks] (b) Write a method category (double height) which returns a suitable type in string form according to the following: Condition Type Tall height >= 200 100 <= height <200 height <100 Medium Short [2 marks] Show transcribed image text Question 4 (a) A class Scanner in Java can be used to get user input and its methods can be used after the following statement is executed: new Scanner (System.in); Scanner input One of its methods nextDouble () returns the next double value from the keyboard. Now you are requested to write a method enterHeight () which displays the message “Input height: ” and uses the method input.nextDouble () to get the user input. The process should be repeated until the input is non-negative. Finally the input should be returned. You can assume the aforementioned statement starting with Scanner has already been executed. [3 marks] (b) Write a method category (double height) which returns a suitable type in string form according to the following: Condition Type Tall height >= 200 100

Expert Answer


Answer to Question 4 (a) A class Scanner in Java can be used to get user input and its methods can be used after the following sta…

OR