Packagestudy01;ImportJava.util.Scanner; Public classSort {/*** Requirement: input three integers by keyboard into variables A, B, C, sort them (using if-else), and from small to large output **/ Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); System.out.print ("A="); intA =Sc.nextint (); System.out.print ("B="); intb =Sc.nextint (); System.out.print ("C="); intc =Sc.nextint (); if(A >b) {if(C >a) {System.out.println (b+ "," + A + "," +c); } Else if(C <b) {System.out.println (c+ "," + B + "," +a); } Else{System.out.println (b+ "," +c+ "," +a); } //when A<<b}Else { if(c<a) {System.out.println (c+ "," +a+ "," +b); }Else if(c>b) {System.out.println (a+ "," +b+ "," +c); }Else{System.out.println (a+ "," +c+ "," +b); } } }}
The output results are as follows:
A=3
b=11
C=1
1,3,11
Keyboard input three integers for small to large order