Techtopz

(@techtopz)

Techtopz is a blog on programming and tech stuff.
Techtopz is now on UpHub.
Follow us for more updates.

    


Java Programming | Multiplication of numbers

This is a tutorial for multiplication of numbers in java. The program is given below that explains in detail. The program is extendable. Go enjoy the program. Let begin…

Program for multiplication of numbers in java

//import Scanner as we require it.
import java.util.Scanner;

// the name of our class its public
public class Multino {
//void main
public static void main (String[] args)
{
//declare int
int w,x,y,z;
//print message
System.out.println("Enter Three numbers:");
//Take input
Scanner input = new Scanner(System.in);
//calculate
w = input.nextInt();
x = input.nextInt();
y = input.nextInt();
z = w * x * y;
//print the product
System.out.println("Product = "+z);
}
}


Output

Enter Three numbers:
1
2
3
Product = 6

How it works
1. The program prints the message to enter numbers.
2. The user enters numbers.
3. Product is calculated.
4. The product is printed.

Extending it
The program can be extended by adding more numbers and calculating their product.

Explanation.
1. Import the Scanner.
2. Declare the class as public
3. Add the void main function
4. Add system.out.println() function with the message to enter numbers.
5. Declare input as Scanner.
6. Take the numbers and save it in variables.
7. Calculate product and save it in other variable.
8. Add system.out.println() function to print the product.

At the end
You learnt creating the Java program for multiplication of numbers. So now enjoy the program.


Login to like the post