Java Program to Multiply Two Numbers

In this Java program, we will use a Scanner to read two integer numbers, multiply both the numbers and finally print the result to the screen.

Java Program to Multiply Two Numbers

package com.javaguides.java.tutorial;

import java.util.Scanner;

/**
 * Java Program to check Even or Odd number
 * 
 * @author https://www.sourcecodeexamples.net/
 *
 */
public class JavaProgramMultiplyNumber {
    public static void main(String[] args) {

        try (Scanner sc = new Scanner(System.in)) {

            // Read number from user
            System.out.println("Enter Number: ");
            int number = sc.nextInt();
            /*
             * If number is divisible by 2 then it's an even number else odd number
             */
            if (number % 2 == 0) {
                System.out.println("The number " + number + " is even");
            } else {
                System.out.println("The number " + number + " is odd");
            }
        }
    }
}
Output:
Enter first number: 10
Enter second number: 20
Output: 200

Related Java Programs

Comments