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

Please rewrite with any corrections to help me compile this pleaseeee import jav

ID: 3626684 • Letter: P

Question

Please rewrite with any corrections to help me compile this pleaseeee

import java.util.Scanner;

public class Prog17 {

public static void main(String[] args) {


Scanner input = new Scanner(System.in);


System.out.print("Enter the first number: ");

double num1 = input.nextDouble();

System.out.print("Enter the second number: ");

double num2 = input.nextDouble();

System.out.print("Enter the third number: ");

double num3 = input.nextDouble();



System.out.println("The numbers in ascending order are: ");

displaySortedNumbers(num1, num2, num3);

}

Explanation / Answer

public void displaySortedNumbers(double num1, double num2, 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);
}

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