Multiply using variables Learn programming Java

Lesson:

First contact with Java


Exercise:

Multiply using variables 40


Objetive:

Write a java program to print the result of multiplying two numbers which will entered by the user.


Code:

import java.util.*;
public class Main
{
	public static void main(String[] args)
	{
		int number1;
		int number2;
		int multiplication;
		System.out.println("Enter 1st number");
		number1 = Integer.parseInt(new Scanner(System.in).nextLine());
		System.out.println("Enter 2nd number");
		number2 = Integer.parseInt(new Scanner(System.in).nextLine());
		multiplication = number1 * number2;
		System.out.println("The multiplication is:");
		System.out.println(multiplication);
	}
}