Q- Write a program to calculate the sum of 2 numbers ?


import java.io.*;
class sum
{
int add(int a, int b)
{
int c=a+b;
return c;
}
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int a=0,b=0;
a=Integer.parseInt(br.readLine());
b=Integer.parseInt(br.readLine());
sum obj=new sum(a,b);
int t=obj.sum(a,b);
System.out.println("The sum is"+t);
}
Advertisements

One thought on “Q- Write a program to calculate the sum of 2 numbers ?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s