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

更新於: 2024-06-21

10K+ 瀏覽量

開啟您的 職業生涯

完成課程後獲得認證

開始學習
廣告
© . All rights reserved.