Walk Lightly on this PLANET and yet leave such a FOOTPRINT that cannot be erased for thousands of Years..!!!
Visit Codstech for Cyber Security related Posts !

Visitors

Showing posts with label core java sum. Show all posts
Showing posts with label core java sum. Show all posts

Tuesday, September 4, 2012

CJ-25 : Addition using constructors

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
*********************************************************************************************
*********************************************************************************************
import java.io.*;
class add
{
    int a,b,c;
    add()
    {
    }
    add(int x,int y)
    {
            a=x;
            b=y;
            c=a+b;
            System.out.println("Addition ="+c);
    }
 }
class sub
{
    int n,m,s;
    sub()
    {
    }
    sub(int h,int j)
    {
        n=h;
        m=j;
        s=n-m;
        System.out.println("Subtraction ="+s);
    }
}
public class con1 
{
    public static void main(String args[])
    {
        add a=new add(10,20);
        sub b=new sub(60,20);
    }   
}
=========================================================================
Output : 
Addition =30
Subtraction =40





Saturday, July 28, 2012

CJ-4 : Sum(user defined values)

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
*********************************************************************************************
Refer Sum(predefined values) also.
*********************************************************************************************
import java.io.*;
class Adduser 
{
public static void main(String args[]) 
{   
     int a,b,sum;
     try
{
DataInputStream x=new DataInputStream(System.in);
System.out.println("Enter two numbers :");
a=Integer.parseInt(x.readLine());
b=Integer.parseInt(x.readLine());
sum=a+b;
System.out.println("Addition= "+sum);
}
   catch(Exception e)
   {
   }
}
}
========================================================================= 
Output : 
Enter two numbers :
30
20
Addition=50.



CJ-3 : Sum(predefined values)

Type the programs in NOTEPAD or DOS prompt itself, for Consol Application.
Type in NETBEANS or ECLIPSE for Window Application.
Here after , I am just typing the programs only..to know more about it , refer

Introduction to JAVA 

before doing any JAVA Programs.
************************************************************************************
Refer Sum(user defined values) also.
************************************************************************************
class Add 
{
public static void main(String args[]) 
{   
     int a,b,c;
     a=20;
     b=40;
     c=a+b;
     System.out.println("Addition="+c);
}
}
=========================================================================
Output : Addition=60.