Write a Java program, in which you input 2 numbers and find the sum and product of the two number in java

 Write a Java program, in which you input 2 numbers and find the sum and product of the two number in java

import java.util.Scanner;
public class SumProduct
{
   public static void main(String args[]){
       int num1,num2,product,sum;
    Scanner input = new Scanner(System.in);
    System.out.println("Enter the 1st number");
    num1=input.nextInt();
    System.out.println("Enter the 2nd number");
    num2=input.nextInt();
    sum=num1+num2;
    product=num1*num2;
    System.out.println("Sum of "+num1+" and "+num2+" is "+sum );
    System.out.println("Product of "+num1+" and "+num2+" is "+product );
    }
}
Output
Sum of 14 and 2 is 16 Product of 14 and 2 is 28

Comments

Popular posts from this blog

Make a GST Calculator using HTML and JavaScript

How to make simple bill maker by using python tkinter

Write a program to find the sum of 1/2+4/3+5/6+8/7+9/10 using loop in java