Java Learning Note 10

Source: Internet
Author: User

31.
Writes a Boolean expression that is true when age is greater than 13 and less than 18 o'clock result
Age > All && Age < 18

32.
Write a Boolean expression that evaluates to true when weight weight is greater than 50 or taller than 160
Weight > 50 | | Height > 160

33.
Writes a Boolean expression that evaluates to True when the weight is weight>50 and height is greater than 160
Weight > && height > 160

34.
A Boolean expression that writes the result to true when the weight weight is greater than 50 or height is greater than 160, but cannot meet both conditions at the same time
Weight > ^ height > 160

The switch statement supports byte,short,char,int,enum,string and does not support long data types

 PackageWelcome;ImportJava.util.Scanner;/** Solve a two -dimensional equation*/ Public classcomputeequation { Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); System.out.print ("Enter A, B, C:"); DoubleA =in.nextdouble (); Doubleb =in.nextdouble (); Doublec =in.nextdouble (); DoubleJudgeexpression = b * b-4 * A *C; DoubleR1 = 0; Doubler2 = 0; if(Judgeexpression > 0) {R1= (-B + math.pow (judgeexpression, 0.5))/(2 *a); R2= (-b-math.pow (judgeexpression, 0.5))/(2 *a); System.out.println ("The Roots is" + r1 + "+" +R2); }Else if(Judgeexpression = = 0) {R1= (-B + math.pow (judgeexpression, 0.5))/(2 *a); System.out.println ("The root is" +R1); }Else{System.out.println ("The equation has no real roots."); }    }}

 PackageWelcome;ImportJava.util.Scanner;/** Check if a number is even*/ Public classCheckeven { Public Static voidMain (string[] args) {Scanner in=NewScanner (system.in); System.out.print ("Enter An integer:"); intNumber =In.nextint (); System.out.printf ("Is%d an even number? %b ", number, (number% 2 = = 0)); }}

Java Learning Note 10

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.