Answer to Question #324624 in Java | JSP | JSF for Hakir

Question #324624
  1. Input three integers.
  2. Print the integers in ascending order.


"IF ELSE - ELSE IF STATEMENT"


Input

A line containing three integers is separated by a space.

6 1 3

Output

A line containing three integers is separated by a space.

1 3 6
1
Expert's answer
2022-04-06T10:14:47-0400


import java.util.Scanner;


public class App {


	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		if (a < b && a < c && b < c) {
			System.out.printf("%d %d %d", a, b, c);
		} else if (b < c && b < a && c < a) {
			System.out.printf("%d %d %d", b, c, a);
		} else if (c < a && c < b) {
			System.out.printf("%d %d %d", c, b, a);
		} else {
			System.out.printf("%d %d %d", a, c, b);
		}


		in.close();
	}


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS