Java 程式用來計算兩個數字的積
在 Java 中,* 運算子用於相乘兩個數字。使用 Scanner 類從使用者讀取所需數字,並使用 * 運算子相乘兩個整數。
示例
import java.util.Scanner;
public class MultiplicationOfTwoNumbers {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of the first number ::");
int a = sc.nextInt();
System.out.println("Enter the value of the first number ::");
int b = sc.nextInt();
int result = a*b;
System.out.println("Product of the given two numbers is ::"+result);
}
}輸出
Enter the value of the first number :: 55 Enter the value of the first number :: 66 Product of the given two numbers is ::3630
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP