Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write the following method to run a prgram that sorts three numbers. public stat

ID: 3630917 • Letter: W

Question


Write the following method to run a prgram that sorts three numbers.
public static void displaySortedNumbers(
double num1, double num2, double num3)


Here is what we have so far but it won't compile or run it is missing a main method


public void displaySortedNumbers(double num1, doublenum2, double num3)
{
// swap numbers so that num1 < num2 < num3
if(num1 > num2)
{
double temp = num1;
num1 = num2;
num2 = temp;
}
if(num1 > num3)
{
double temp = num3;
num3 = num1;
num1 = temp;
}
// now num1 is smallest
if(num2 > num3)
{
double temp = num3;
num3 = num2;
num2 = temp;
}
// print numbers
System.out.println(num1+" "+num2+" "+num3);
}

Explanation / Answer

import java.util.Scanner; public class IncreasingOrder { public static void main(String[] args){ Scanner scan=new Scanner(System.in); double a,b,c; a=scan.nextDouble(); b=scan.nextDouble(); c=scan.nextDouble(); displaySortedNumbers(a,b,c); } scan.close(); }//end main public static void displaySortedNumbers(double num1, double num2, double num3) { // swap numbers so that num1 num3) { temp = num3; num3 = num1; num1 = temp; } // now num1 is smallest if(num2 > num3) { temp = num3; num3 = num2; num2 = temp; } // print numbers System.out.println(num1+" "+num2+" "+num3); }//end fxn }//end class