Question: Write a program that prompts the user to enter three integers and displays the integers in ascending order. Below are 4 sample runs: ``` Enter

Write a program that prompts the user to enter three integers and displays the integers in ascending order.

Below are 4 sample runs: ``` Enter 3 numbers: 3 2 1 The numbers in sorted order are: 1 2 3

Enter 3 numbers: 11 0 0 The numbers in sorted order are 0 0 11

Enter 3 numbers: -3 2 1 The numbers in sorted order are: -3 1 2

Enter 3 numbers: 1 2 3 The numbers in sorted order are: 1 2 3

//For some reason the program isn't outputting anything

Can anyone help me with this problem? I'm not understanding the way this is supposed to work.

import java.util.Scanner;

public class Lab5b {

public static void main(String[] args) {

int n1,n2,n3 ;

System.out.print("Enter 3 numbers: ");

Scanner in = new Scanner(System.in);

n1=nextInt();

n2=nextInt();

n3=nextInt();

if(n1>n2 && n2>n3 && n1>n3)

System.out.print("The numbers in sorted order are: "+n1+n2+n3);

else if(n2

System.out.print("The numbers in sorted order are: "+n2+n3+n1);

}

}

private static int nextInt() {

Scanner in= new Scanner(System.in);

return 0;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!