Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

AWS Certified Database Study Guide Specialty DBS-C01 Exam

Authors: Matheus Arrais, Rene Martinez Bravet, Leonardo Ciccone, Angie Nobre Cocharero, Erika Kurauchi, Hugo Rozestraten

1st Edition

1119778956, 978-1119778950

More Books

Students also viewed these Databases questions

Question

What are POP3 and IMAP?

Answered: 1 week ago

Question

3. Explain the forces that influence how people handle conflict

Answered: 1 week ago