Question: Sort Three Numbers (Java) Write a void method that accepts three floating point numbers and displays the numbers in ascending (increasing) order. Your method should

Sort Three Numbers (Java)

Write a void method that accepts three floating point numbers and displays the numbers in ascending (increasing) order.

Your method should include:

if statements to sort the numbers

An extra variable to sort (transfer) the values from one variable to another

The first variable should store the smallest number, and the third variable should store the largest number after sorting

An output statement to display the sorted numbers

Test the method by writing a program that prompts the user to enter the three numbers and invokes the method to display the numbers.

Samples of the output are shown below:

Enter three values: 76.4 8.9 45.7 The sorted numbers are 8.9 45.7 76.4

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!