Write a java program for two multiply number - Free Web Development || UI Development || React JS || Angular

Latest

Free Web Development ||Free UI Development || React JS || HTML5 || CSS3 || JavaScript || Angular Learn Web Development || Frontend Developer || Full Stack Developer

1 / 3
Welcome to Shravan Ghanchi
2 / 3
3 / 3

Sunday, December 13, 2020

Write a java program for two multiply number

 Multiplication program in Java 

In the Multiplication program user to enter integer and display to product.

Process for Write a java program:

(1) Make a class multiplication

(2)Take 3 variable like num1,num2,product;

(3) Entered number by the user with help of the Scanner class.

(4) Use the formula product1=num1*num2;

(5)Display the product of multiply in Java.



Program Code:

package com;

import java.util.Scanner;

public class Mutliplication {

   public static void main(String[] args) {

       // TODO Auto-generated method stub

           int num1,num2,product;

          Scanner sc=new Scanner(System.in);

     System.out.print("Enter your first number:");

     num1=sc.nextInt();

    System.out.print("Enter your second number:");

     num2=sc.nextInt();

    sc.close();

    product=num1*num2;

    System.out.println("Output:"+product);

     }

}

Output:

Enter your first number:10

Enter your second number:10

Output:100

Note: If the number is in floating point we just take the variable of float instead of Int Thats all.Thanku so much for read my article.



No comments:

Post a Comment

Snow
Forest
Mountains
Snow
Forest
Mountains