1 PackageXuexi;2 3 ImportJava.util.Scanner;4 5 Public classLianxi {6 7 Public Static voidMain (string[] args) {8 9System.out.println ("Please enter 1 numbers and return");TenScanner in =NewScanner (system.in); One inti1=in.nextint (); ASystem.out.println ("Please enter 1 sets of numbers and return"); - intI2=in.nextint (); - inti3=i1+I2; theSystem.out.println ("Sum of 2 groups of numbers =" +i3); - - - + } - +}Enter 2 numbers and add sums
1 PackageXuexi;2 3 ImportJava.util.Scanner;4 5 Public classFenzhiyuju {6 7 Public Static voidMain (string[] args) {8 9Scanner in =NewScanner (system.in);Ten intA = 1;//1. Short sleeves 2, long sleeves OneSYSTEM.OUT.PRINTLN ("Please select Type (1, short sleeve 2, long sleeves)"); AA =in.nextint (); - - if(A = = 1) { theSYSTEM.OUT.PRINTLN ("I want to buy short sleeves"); -SYSTEM.OUT.PRINTLN ("Please select color: (1, White, 2 for Black)"); - intb =in.nextint (); - if(b = = 1) { +System.out.println ("I chose white.")); -}Else { +System.out.println ("I chose black.")); A } at } - - Else { -System.out.println ("I chose long sleeves"); -SYSTEM.OUT.PRINTLN ("Please select color (1, yellow, 2, green)"); - intc =in.nextint (); in if(c = = 1) { -System.out.println ("I chose yellow"); to}Else { +System.out.println ("I chose green"); - } the * } $System.out.println ("This is the dress you want, please.");Panax Notoginseng - } the}buy clothes to choose
Import Java.util.Scanner; Reference
Scanner in = new Scanner (system.in);
A = In.nextint ();
Branch statement (IF) Practice Java code