Saturday, 26 July 2014

Write a Program to Prints Prime Numbers using java



package topstechnology;import java.util.*;
public class primenumber {
    public static void main(String []args)
  {
    Scanner sc = new Scanner(System.in);
    int i,n,res;
    boolean flag=true;
    System.out.println("Enter the No.");
    n = sc.nextInt();
    for(i=2;i<=n/2;i++)
    {
        res = n%i;
        if(res==0)
        {
                flag =false;
                break;
        }
    }
    if(flag)
            System.out.println(n + " is Prime Number");
        else
            System.out.println(n + " is not Prime Number");
    }
}


OutPut

 




Write a Program to Calculate Fibonacci Series using Do-while Loop for Java

public class fibonacci
{
              public static void main(String []args)
              {
                       int pre = 0;
                       int next - 1;
                       int current;
                       System.out.println(pre);
                       System.out.println(next);

                       do  
                      {
                             current = next + pre;
                             System.out.println(current);
                           
                              pre = next;
                              next = current;
                           
                      }
                      while(next<=100);
                 
               }
                  
}

Output

Write a Program that calculates and prints the simple interest using the formula : Simple Interest = PNR/100

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        int p,n,r,Ans;
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter the Value of P : ");
        p = sc.nextInt();
        System.out.println("Enter the Value of N : ");
        n = sc.nextInt();
        System.out.println("Enter the Value of R : ");
        r = sc.nextInt();

        Ans = (p*n*r)/100;
        System.out.println("Interest is : "+Ans);
       
    }

}




OutPut :






Thursday, 17 July 2014

Calculated Value Entered By User Using Java Program

import java.util.Scanner;
class first
{
    Scanner sc = new Scanner(System.in);
    void Add()
    {   
        int a,b,c;
        System.out.println("Enter the Value of A:");
        a=sc.nextInt();
        System.out.println("Enter the value of B:");
        b = sc.nextInt();
        c=a+b;
        System.out.println(c);
    }
    void Minus()
    {
        int x,y,z;
        System.out.println("Enter the value of X:");
        x=sc.nextInt();
        System.out.println("Enter the value of Y:");
        y=sc.nextInt();
        z = x-y;
        System.out.println(z);
    }
    void Mul()
    {
        int a,b,c;
        System.out.println("Enter the value of A:");
        a = sc.nextInt();
        System.out.println("Enter the value of B:");
        b = sc.nextInt();
        c=a*b;
        System.out.println(c);
       
       
    }

void Div()
    {
        int a,b,c;
        System.out.println("Enter the value of A:");
        a = sc.nextInt();
        System.out.println("Enter the value of B:");
        b = sc.nextInt();
        c=a/b;
        System.out.println(c);
       
       
    }

void Mod()
    {
        int a,b,c;
        System.out.println("Enter the value of A:");
        a = sc.nextInt();
        System.out.println("Enter the value of B:");
        b = sc.nextInt();
        c=a%b;
        System.out.println(c);
       
       
    }
   
}
class second
{
    public static void main(String args[])
    {
        first f = new first();
        f.Add();
        f.Minus();
        f.Mul();
        f.Div();
        f.Mod();
    }
}

OutPut


Wednesday, 16 July 2014

Simple Hellow World Program using Java Programming Language

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


OutPut :


Followers