Search This Blog

If you have any problem or question please write in the comments. We will try to solve and send you the solution. Not just that we will also post your problems solution on our blog.

Thursday, 1 September 2011

Java program to find sum and product of two numbers

It is very easy to find sum and product of two numbers in java. First of all we must take two numbers from user and then we will add and multiply these numbers. Lets see how, it is

import java.util.*;
class sumproduct
public static void main (String args[])
Scanner in = new Scanner (;
int a,b,s,p;
System.out.print ("\n\t Enter first number = ");
System.out.print ("\n\t Enter second number = ");
System.out.print ("\n\t sum = "+s);
System.out.print ("\n\t product = "+p);

          After we have the numbers, take two variables for sum and product. As we have s and p in this program.