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
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