This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.

Sunday, May 5, 2013

Simple addition Program Using Java

import java.lang.*;
import java.io.*;
class Add
{
    public static void main(String args[])
    {
        int x=10,y=7,z;
        z=x+y;
        System.out.println("The result is:"+z);
    }
}

Write a java Program to find the area of the Circle formula

import java.lang.*;
import java.io.*;
class Circlearea
{
    public static void main(String args[])
    {
        float pi=3.14159f,area;
        int r=5;
        area=pi*r*r;
        System.out.println("The area of the circle is:"+area);
    }
}

Write a java Program to find the Quadratic Equation roots

import java.lang.*;
import java.io.*;
class Quadratic
{
    public static void main(String args[])
    {
        double b=12.1,a=2.35,c=12.50,dis,root1,root2;
        dis=(b*b)-(4*a*c);
        root1=(-b+Math.sqrt(dis)/2*a);
        root2=(-b-Math.sqrt(dis)/2*a);
        if(root1<=0 && root2<=0)
        {
            System.out.println("Roots are imaginary");
        }
        else
        {
        System.out.println("The result is:"+root1);
        System.out.println("The result is:"+root2);
        }
    }
}
       

Write a java Program to find the Simple Interest rate


import java.lang.*;
import java.io.*;
class Simpleinterest
{
    public static void main(String args[])
    {
        int p=5000,t=12,r=3;
        int interest=((p*t*r)/100);
        System.out.println("The Simple interest is:"+interest);
    }
}

The Fibonacci sequence is defined by the following rule. The first 2 values in the sequence are 1,1. Every subsequent value is the sum of the 2 values preceding it. Write A Java Program (WAJP) that uses both recursive and non-recursive functions to print the nth value of the Fibonacci sequence.


/* Fibonacci series Program in Java */

/*1.Fibonacci program using Non-Recursive Functions*/

import java.lang.*;
import java.io.*;
class Fibonacci
{
    public static void main(String args[])throws IOException
    {
    int i,sum=0,f=1,res,n;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Hey boss This is Fibonacci series Generator program");
    System.out.println("Enter The range");
    n=Integer.parseInt(br.readLine());
    System.out.println("The fibonacci series is:");
    for(i=0;i<n;i++)
    {
        res=sum+f;
        System.out.println(sum);
        sum=f;
        f=res;
    }
    System.out.println("\nTask completed.");
    }
}

Output:

Hey boss This is Fibonacci series Generator program
Enter The range
20
The fibonacci series is:
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181

Task completed.

Twitter Delicious Facebook Digg Stumbleupon Favorites More