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
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