Tool version compatibility problem
Arithmetic operators
Correct
Basically :
+ - * / %
Self increasing Self subtraction
++ --
This video is interpretive , So I hope you have read the content of this knowledge point , And after writing the corresponding code , Watch with questions , Only in this way can we gain more . It is not recommended to watch the video at the beginning
![]() 13 branch 21 second This video uses html5 Play mode , If it cannot be played normally , Please upgrade your browser to the latest version , Recommend Firefox ,chrome,360 browser . If thunderbolt is installed , Play the video and show the direct download status , Please adjust Thunderbolt system settings - Basic settings - Start - Monitor all browsers ( Remove this option ). chrome of Video download Plug-in will affect playback , as IDM etc. , Please close or switch other browsers Example 1 : Basic arithmetic operators Example 2 : practice - Sum Example 3 : answer - Sum Example 4 : The length of any arithmetic unit exceeds int Example 5 : The length of any arithmetic unit is less than int Example 6 : % Take the mold Example 7 : Self increasing Self subtraction Example 8 : Self increasing The difference between before and after the subtraction operator Example 9 : practice - Self increasing Example 10 : answer - Self increasing Example 11 : practice -BMI Example 12 : answer -BMI + - * / Basic plus Minus Take except
public class HelloWorld { public static void main(String[] args) { int i = 10; int j = 5; int a = i+j; int b = i - j; int c = i*j; int d = i /j; } }
public class HelloWorld { public static void main(String[] args) { int i = 10; int j = 5; int a = i+j; int b = i - j; int c = i*j; int d = i /j; } }
use
Scanner Get two numbers from the console , Then calculate the sum of these two numbers
If you can't use Scanner, Please refer to How to use Scanner Read integers
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Viewing this answer will cost 3 Points , You currently have a total of Point integral . It doesn't cost extra points to see the same answer . Points increase method Or One time purchase JAVA Base total 0 One answer ( Total required 0 Integral )
Viewing this answer will cost 3 Points , You currently have a total of Point integral . It doesn't cost extra points to see the same answer . Points increase method Or One time purchase JAVA Base total 0 One answer ( Total required 0 Integral )
Account not activated
Account not activated , Limited functionality . Please click activate
This video is interpretive , So I hope you have read the content of this answer , Watch with questions , Only in this way can we gain more . It is not recommended to watch the video at the beginning
![]() 2 branch 2 second This video uses html5 Play mode , If it cannot be played normally , Please upgrade your browser to the latest version , Recommend Firefox ,chrome,360 browser . If thunderbolt is installed , Play the video and show the direct download status , Please adjust Thunderbolt system settings - Basic settings - Start - Monitor all browsers ( Remove this option ). chrome of Video download Plug-in will affect playback , as IDM etc. , Please close or switch other browsers
import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { Scanner s = new Scanner(System.in); int a = s.nextInt(); System.out.println(" The first integer :"+a); int b = s.nextInt(); System.out.println(" The second integer :"+b); int c = a+b; System.out.println(" The sum of two numbers is :" + c); } }
import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { Scanner s = new Scanner(System.in); int a = s.nextInt(); System.out.println(" The first integer :"+a); int b = s.nextInt(); System.out.println(" The second integer :"+b); int c = a+b; System.out.println(" The sum of two numbers is :" + c); } }
If any arithmetic unit is longer than int, Then the calculation result is calculated according to the longest length
For example int a = 5; long b = 6; a+b -> The result type is long
public class HelloWorld { public static void main(String[] args) { int a = 5; long b = 6; int c = (int) (a+b); //a+b The result of the operation is long Type , So we need to cast long d = a+b; } }
public class HelloWorld { public static void main(String[] args) { int a = 5; long b = 6; int c = (int) (a+b); //a+b The result of the operation is long Type , So we need to cast long d = a+b; } }
If the length of any arithmetic unit does not exceed int, Then the result is calculated according to int To calculate
byte a = 1; byte b= 2; a+b -> int type
public class HelloWorld { public static void main(String[] args) { byte a = 1; byte b= 2; byte c = (byte) (a+b); // Although a b It's all byte type , But the result is int type , Cast required int d = a+b; } }
public class HelloWorld { public static void main(String[] args) { byte a = 1; byte b= 2; byte c = (byte) (a+b); // Although a b It's all byte type , But the result is int type , Cast required int d = a+b; } }
% Take the remainder , Also called mold taking
5 divide 2, I 1
public class HelloWorld { public static void main(String[] args) { int i = 5; int j = 2; System.out.println(i%j); // The output is 1 } }
public class HelloWorld { public static void main(String[] args) { int i = 5; int j = 2; System.out.println(i%j); // The output is 1 } }
++
-- Add... On the original basis 1 Or reduce 1
public class HelloWorld { public static void main(String[] args) { int i = 5; i++; System.out.println(i);// The output is 6 } }
public class HelloWorld { public static void main(String[] args) { int i = 5; i++; System.out.println(i);// The output is 6 } }
With ++ take as an example
int i = 5; i++; Take the value first , Then calculate ++i; First calculate , Take another value
public class HelloWorld { public static void main(String[] args) { int i = 5; System.out.println(i++); // Output 5 System.out.println(i); // Output 6 int j = 5; System.out.println(++j); // Output 6 System.out.println(j); // Output 6 } }
public class HelloWorld { public static void main(String[] args) { int i = 5; System.out.println(i++); // Output 5 System.out.println(i); // Output 6 int j = 5; System.out.println(++j); // Output 6 System.out.println(j); // Output 6 } } int i = 1; int j = ++i + i++ + ++i + ++i + i++; ask j What is the result of ? notes : Don't put it in eclipse In , According to ++ Front setting After the understanding, calculate it yourself first , Then look at the answer
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Viewing this answer will cost 3 Points , You currently have a total of Point integral . It doesn't cost extra points to see the same answer . Points increase method Or One time purchase JAVA Base total 0 One answer ( Total required 0 Integral )
Viewing this answer will cost 3 Points , You currently have a total of Point integral . It doesn't cost extra points to see the same answer . Points increase method Or One time purchase JAVA Base total 0 One answer ( Total required 0 Integral )
Account not activated
Account not activated , Limited functionality . Please click activate
This video is interpretive , So I hope you have read the content of this answer , Watch with questions , Only in this way can we gain more . It is not recommended to watch the video at the beginning
![]() 2 branch 26 second This video uses html5 Play mode , If it cannot be played normally , Please upgrade your browser to the latest version , Recommend Firefox ,chrome,360 browser . If thunderbolt is installed , Play the video and show the direct download status , Please adjust Thunderbolt system settings - Basic settings - Start - Monitor all browsers ( Remove this option ). chrome of Video download Plug-in will affect playback , as IDM etc. , Please close or switch other browsers
public class HelloWorld { public static void main(String[] args) { int i = 1; int j = ++i + i++ + ++i + ++i + i++; //i value 2 3 4 5 6 // Value 2 2 4 5 5 System.out.println(j); } }
public class HelloWorld { public static void main(String[] args) { int i = 1; int j = ++i + i++ + ++i + ++i + i++; //i value 2 3 4 5 6 // Value 2 2 4 5 5 System.out.println(j); } }
use
Scanner Collect your height and weight , And calculate your BMI What is the value
BMI The formula is weight (kg) / ( height * height ) For example, Qiu Yangbo's weight is 72kg, Height is 1.69, So this classmate's BMI namely 72 / (1.69*1.69) = ? reference resources : use Scanner How to read floating point numbers
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Before looking at the answers , Try to finish it yourself first , See the answer when you encounter a problem , The harvest will be more
Viewing this answer will cost 4 Points , You currently have a total of Point integral . It doesn't cost extra points to see the same answer . Points increase method Or One time purchase JAVA Base total 0 One answer ( Total required 0 Integral )
Viewing this answer will cost 4 Points , You currently have a total of Point integral . It doesn't cost extra points to see the same answer . Points increase method Or One time purchase JAVA Base total 0 One answer ( Total required 0 Integral )
Account not activated
Account not activated , Limited functionality . Please click activate
This video is interpretive , So I hope you have read the content of this answer , Watch with questions , Only in this way can we gain more . It is not recommended to watch the video at the beginning
![]() 4 branch 19 second This video uses html5 Play mode , If it cannot be played normally , Please upgrade your browser to the latest version , Recommend Firefox ,chrome,360 browser . If thunderbolt is installed , Play the video and show the direct download status , Please adjust Thunderbolt system settings - Basic settings - Start - Monitor all browsers ( Remove this option ). chrome of Video download Plug-in will affect playback , as IDM etc. , Please close or switch other browsers
import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println(" Please enter your height (m):"); float height = s.nextFloat(); System.out.println(" Please enter your weight (kg):"); float weight = s.nextFloat(); float BMI = weight/ (height*height); System.out.println(" Current BMI yes : " + BMI); } }
import java.util.Scanner; public class HelloWorld { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println(" Please enter your height (m):"); float height = s.nextFloat(); System.out.println(" Please enter your weight (kg):"); float weight = s.nextFloat(); float BMI = weight/ (height*height); System.out.println(" Current BMI yes : " + BMI); } }
The official account of programming , Follow and get the latest tutorials and promotions in real time , thank you .
![]()
Q & A area
2021-10-05
It seems that it's OK to write like this , Not used long There should be no problem ?
6 One answer
JZLong Jump to the problem location Answer time :2021-11-03 Hard working snail i Jump to the problem location Answer time :2021-10-30 jonty99 Jump to the problem location Answer time :2021-10-19
package lian; import java.util.Scanner; public class shuru { public static void main(String[] args){ System.out.println(" Please enter your weight (kg):"); Scanner scanner = new Scanner(System.in); double weight = scanner.nextDouble(); System.out.println(" Please enter your height (m):"); //Scanner scanner = new Scanner(System.in); double height = scanner.nextDouble(); double BMI=weight/(height*height); System.out.println(BMI); }
Ogawa GG Jump to the problem location Answer time :2021-10-17 c128ve980 Jump to the problem location Answer time :2021-10-15
package How2; import java.util.Scanner; public class ScannerTest { public static void main(String[] args) { System.out.println(" Please enter your weight (kg):"); Scanner scanner = new Scanner(System.in); double weight = scanner.nextDouble(); System.out.println(" Please enter your height (m):"); double height = scanner.nextDouble(); double BMI = weight/(height*height); System.out.println(BMI); } }
Please enter your weight (kg): 85 Please enter your height (m): 1.75 27.755102040816325 Yan Chan Jump to the problem location Answer time :2021-10-10
The answer has been submitted successfully , Auditing . Please
My answer Check the answer record at , thank you
2021-09-16
When casting , What shortcut key did you enter when ? It changes in a moment
2 One answer
Hard working snail i Jump to the problem location Answer time :2021-10-30 jonty99 Jump to the problem location Answer time :2021-10-19
package lian; import java.util.Scanner; public class shuru { public static void main(String[] args){ System.out.println(" Please enter your weight (kg):"); Scanner scanner = new Scanner(System.in); double weight = scanner.nextDouble(); System.out.println(" Please enter your height (m):"); //Scanner scanner = new Scanner(System.in); double height = scanner.nextDouble(); double BMI=weight/(height*height); System.out.println(BMI); }
The answer has been submitted successfully , Auditing . Please
My answer Check the answer record at , thank you
2021-08-28
BMI practice
2021-07-23
Why? scanner s of s Will report an error
2021-07-03
calculation BMI Applet for
Too many questions , Page rendering is too slow , To speed up rendering , Only a few questions are displayed on this page at most . also 99 Previous questions , please Click to view
Please... Before asking questions land
The question has been submitted successfully , Auditing . Please
My question Check the question record at , thank you
|