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

Write a method with the following header to display three numbers in increasing

ID: 3761871 • Letter: W

Question

Write a method with the following header to display three numbers in increasing order: public static void display SortedNumbers(double num1, double num2, double num3) You will also need a temp variable (int) to perform the necessary operations to sort the numbers so they display as num1 <= num2 <= num3 depending on the appropriate order. . It introduces the temp variable on lines 11-13. . However, in this program, there will be three distinct if statement code blocks in the method. The first if code block will look like: if (num1 > num2) { int temp = num1; num1 = num2; num2 = temp; } if (num2>num3) {}// complete code - look at pattern in above code block– replace num1 and num2 with num2 and num3 respectively if (num1 > num2) {} // complete code- repeat the original if block Write a test program that prompts the user to enter three numbers and invokes the method to display these numbers in increasing order so you will need to declare num1, num2 and num3 in the main() method

Explanation / Answer

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class SortedDisplay
{
public static void DisplaySortedNumbers(double num1,double num2,double num3)
{
if(num1>=num2)
{
if(num1>=num3)
{
if(num3>=num2)
System.out.println(num2+" "+num3+" "+num1);
else
System.out.println(num3+" "+num2+" "+num1);
}
else
System.out.println(num2+" "+num1+" "+num3);
}
else
{
if(num2>=num3)
{
if(num3>=num1)
System.out.println(num1+" "+num3+" "+num2);
else
System.out.println(num3+" "+num1+" "+num2);
}
else
System.out.println(num1+" "+num2+" "+num3);
}
}
  
  
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner input = new Scanner(System.in);
double num1,num2,num3;
  
System.out.print("Input number 1 : ");
num1 = input.nextDouble();
  
System.out.print("Input number 2 : ");
num2 = input.nextDouble();
  
System.out.print("Input number 3 : ");
num3 = input.nextDouble();
  
System.out.println("In ascending order " );
ascendingOrder(num1,num2,num3);

}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote