Java basic Syntax (b) < operators >

Source: Internet
Author: User

  Operator:

    

The following are the relevant exercises:

1, the keyboard input a three-bit integer number, please obtain the value of each digit of the three digit number respectively

ImportJava.util.Scanner; Public classTest02 { Public Static voidMain (string[] args) {System.out.println ("Please enter a three-bit integer:"); intValue =NewScanner (system.in). Nextint (); intGewei = value% 10; intShiwei = (VALUE/10)% 10; intBaiwei = value/100; System.out.println ("Number" + value + "The digit is" + Gewei + ", 10 bits is" +Shiwei+ ", Hundred is" +Baiwei); }}

2, say the results of the operation:

 Public class Test03 {        publicstaticvoid  main (string[] args) {             int x = 4;              int y = (--x) + (x--) + (x*10);             SYSTEM.OUT.PRINTLN (//  y = +; x = 2        }    }
 Public classTest05 { Public Static voidMain (string[] args) { Shorts = 30; inti = 50; S+=i; System.out.println ("s=" +s);//s =            intx = 0; inty = 0; intz = 0; Booleanb; A= x>0 & y++>1; System.out.println ("A=" +a);//A = FalseSystem.out.println ("y=" +y);//y = 1b = x>0 && z++>1; System.out.println ("b=" +b);//B = FalseSystem.out.println ("z=" +z);//z = 0A = X>0 | Y++>1; System.out.println ("A=" +a);//A = FalseSystem.out.println ("y=" +y);//y = 2b = X>0 | | Z++>1; System.out.println ("b=" +b);//B = FalseSystem.out.println ("z=" +z);//z = 1        }    }

3, keyboard input three int type number, 1) to find the minimum value of three numbers and print, 2) to find the number of three and print

ImportJava.util.Scanner; Public classTest07 { Public Static voidMain (string[] args) {Scanner sc=NewScanner (system.in); System.out.println ("Please enter the first integer:"); intNUM1 =Sc.nextint (); System.out.println ("Please enter a second integer:"); intnum2 =Sc.nextint (); System.out.println ("Please enter a third integer:"); intNUM3 =Sc.nextint (); //calculate the maximum value in three numbers        intMinValue = Num1 < num2? (Num1 < num3 num1:num3):(num2 < num3?num2:num3); System.out.println (NUM1+ "," + num2 + "," + num3+ "the minimum value in the three numbers is:" +minValue); //calculate the three andSystem.out.println (Num1 + "," + num2 + "," + num3+ "of these three numbers and:" + (num1+num2+num3)); }}

Java basic Syntax (b) < operators >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.