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