Java Tut 46 : Thêm 2 số 0 (0)

Java Tut 46 : Thêm 2 số 0 (0)

Java Tut 46 : Thêm 2 số 0 (0)

Learn more »

Thêm hai số

Tìm hiểu cách thêm hai số trong Java:

Thí dụ

int x = 5; int y = 6; int sum = x + y; System.out.println(sum); // Print the sum of x + y 

Hãy tự mình thử »


Thêm hai số với đầu vào của người dùng

Tìm hiểu cách thêm hai số bằng đầu vào của người dùng:

Thí dụ

import java.util.Scanner; // Import the Scanner class  class MyClass {   public static void main(String[] args) {     int x, y, sum;     Scanner myObj = new Scanner(System.in); // Create a Scanner object     System.out.println("Type a number:");     x = myObj.nextInt(); // Read user input      System.out.println("Type another number:");     y = myObj.nextInt(); // Read user input      sum = x + y;  // Calculate the sum of x + y     System.out.println("Sum is: " + sum); // Print the sum   } }  

Chạy ví dụ »


Lượt xem : 223

Integrations
Users

Share Profile

Anyone at KeenThemes can view
Anyone with link can edit

Give Award

Anyone at KeenThemes can view
Anyone with link can edit

Report User

Let us know why you’re reporing this person
Don't worry, your report is completely anonymous; the person you're
reporting will not be informed that you've submitted it