Question
Write a method named orderEnds() (including the header) that takes an array of doubles and, if the first element is larger than the last element
Write a method named orderEnds() (including the header) that takes an array of doubles and, if the first element is larger than the last element, swaps those two elements in the array. Otherwise, the method makes no changes to the array.
Your solution should not create any additional arrays or ArrayLists
For example:
if nums is {4.0, 8.9, 7.2, 1.0}, then orderEnds(nums) will change the array to be {1.0, 8.9, 7.2, 4.0}
if nums is {99.0, 96.3, 100.0}, then orderEnds(nums) will make no change to the array
if nums is {65.7}, then orderEnds(nums) will make no change to the array
if nums is { }, then orderEnds(nums) will make no change to the array
// Write the method header and implement the method
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