Problem: 2.5


 Question 2.5:Write a Java program that takes two numbers as input and display the product of two numbers.

Test Data:

Input first number: 25

Input second number: 5

Expected Output:

25 x 5 = 125


Solution:

package com.company;
import java.util.Scanner;


public class lab2problem05{

    public static void main(String[] args)
    {
        Scanner Obj =new Scanner(System.in);

            System.out.println("Input fist number: ");
            int n = Obj.nextInt();
            System.out.println("Input second number:");
            int m = Obj.nextInt();

            int result = n*m;
            System.out.println(n + " x " + m + " = " + result);
        }
    }

Previous Post Next Post