Your Ad Here
Showing posts with label java program. Show all posts
Showing posts with label java program. Show all posts

Friday, 6 January 2012

Write a Program to explain the concept of Arithmetic Operators in java


class arithemetic
{
            public static void main(String args[])
            {
                        float a=12, b=2;
                        System.out.println("a= " +a);
                        System.out.println("b= " +b);
                        System.out.println("a+b= " +(a+b));
                        System.out.println("a-b= " +(a-b));
                        System.out.println("a*b= " +(a*b));
                        System.out.println("a/b= " +(a/b));
                        System.out.println("a%b= " +(a%b));
            }
}

# Write a program to add two numbers using function in java


class add
          {
            void add1 (int x,int y)
            {
                        int c=x+y;
                        System.out.println("The Result is:" +c);
            }
}

class main
{
            public static void main(String args[])
            {
                        add a=new add();
                        a.add1(2,3);
            }
}

Write a program to display a simple text on the screen in java


class a
{
            public static void main(String args[])
            {
                        System.out.println("Hello!!!!");
            }
}