FileMiddles.javacontains an incomplete program. program, by defining apickMiddlefunction, and by modifying the existinguserDoublefunction:...
View the step-by-step solution to:

Question

# File Middles.java contains an incomplete program. program, by defining a pickMiddle function, and by modifying

the existing userDouble function:

• pickMiddle takes three arguments, called first, second, third.
• pickMiddle(first, second, third) returns the middle of the values of the three arguments.
• Function userDouble takes one argument, called message, which is a string.
• Function userDouble prints out the message, and then enters a loop, where:
• The program waits for the user to enter a double number.
• If the user enters an invalid number, the function prints that what the user entered "is not a valid double".
• If the user enters "q" or "Q", then the program exits (the code provided already takes care of that).
• If the user enters indeed a valid double number, the function returns that number.

IMPORTANT: You are NOT allowed to modify in any way the main function.

This is an example run of the complete program:

please enter the first number, or q to quit: 5

please enter the second number, or q to quit: 5

please enter the third number, or q to quit: 5

the middle value is 5.0

please enter the first number, or q to quit: 5.1

please enter the second number, or q to quit: 3.2

please enter the third number, or q to quit: 7.5

the middle value is 5.1

please enter the first number, or q to quit: 7

please enter the second number, or q to quit: 8

please enter the third number, or q to quit: 9

the middle value is 8.0

please enter the first number, or q to quit: 3

please enter the second number, or q to quit: 3

please enter the third number, or q to quit: 4

the middle value is 3.0

please enter the first number, or q to quit: 4

please enter the second number, or q to quit: 4

please enter the third number, or q to quit: 3

the middle value is 4.0

please enter the first number, or q to quit: 4

please enter the second number, or q to quit: 3

please enter the third number, or q to quit: 3

the middle value is 3.0

please enter the first number, or q to quit: 1

please enter the second number, or q to quit: 88

please enter the third number, or q to quit: 15

the middle value is 15.0

please enter the first number, or q to quit: -4

please enter the second number, or q to quit: -1

please enter the third number, or q to quit: 56

the middle value is -1.0

please enter the first number, or q to quit: q

Exiting...

Java code import java.util.Scanner; public class Middles { static Scanner input = new Scanner(System. in ); public... View the full answer

### Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

• ### -

Study Documents

Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

Browse Documents