Java Problem Summary 13-input and output from the keyboard, plus three numbers from the keyboard, output and sort from large to small.
Package java2;/** * This is a test from the keyboard input and output * @author xubo601450868 * @time 2015.8.26 * @version v1.0 * */import JAVA.UTIL.SCA Nner;public class Test4 {public static void main (string[] args) {Scanner s=new Scanner (system.in); System.out.println ("Please enter a string"); String S1=s.next (); System.out.println ("Please enter the first number"); int I1=s.nextint (); System.out.println ("Please enter a second number"); int I2=s.nextint (); System.out.println ("Please enter a third number"); int I3=s.nextint ();//s.nextdouble ()/s.nextboolean () other analogy//int swap; if (I1>I2) {if (I1>I3) {if (i2>i3) {System.out.println (i1+ "" +i2+ "" +i3 ");} else {i2=i2^i3; i3=i2^i3; i2=i2^i3; System.out.println (i1+ "" +i2+ "" +i3);}} else{System.out.println (i3+ "" +i1+ "" +i2);}} else{if (i2>i3) {if (i1>i3) {System.out.println (i2+ "" +i1+ "" +i3 ");} else {System.out.println (i2+ "" +i3+ "" +i1);}} else{System.out.println (i3+ "" +i2+ "" +i1);}} System.out.println ("Input string is:" +S1); SYSTEM.OUT.PRINTLN ("Input integer is:" +i1); Boolean B; if (B=false) {}}}
Results:
Please enter a string test Please enter the first number 3 Please enter the second number 1 Please enter a third digit 3 1input string is:testinput integer is:3
Analysis: only int and string are tested. S.nextdouble ()/s.nextboolean () other analogy.
When using a or operation to exchange two variable data.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java Issue Summary 13-input and output from keyboard