Java Programming: Write a JAVA Program to prime number from an array of numbers.

Posted on:
tags: ,

      Write a JAVA Program to prime number from an array of numbers.
import java.io.*;
public class a17 {



public static boolean isprime (int n)
{
for(int i=2;i<=(n/2);i++)
  {
     if(n%i==0)
       return false;
  }
  return true;
 }

public static int readint ()
{
  int n=0;
  try
  {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(br.readLine());
  }catch(IOException e)
 {
   System.out.println("input output error");
   System.exit(1);
  }
  return n;
}
public static void main(String args[])throws IOException{

    System.out.println("enter the size of array");
    int n = a17.readint();
    int a[]=new int[n];

    for(int i=0;i<n;i++){
       System.out.println("enter "+ i+"th number");
        a[i] = a17.readint();}
     for(int i=0;i<n;i++)
     {
             System.out.println(a[i]);
     }

    for(int i=0;i<n;i++){
           if(!a17.isprime(a[i]))
               System.out.println(a[i] + "is not prime ");
            else
                System.out.println(a[i] + "is prime ");
  }}}

OUTPUT:
enter the size of array
3
enter 0th number
22
enter 1th number
11
enter 2th number
33
22
11
33
22is not prime
11is prime
33is not prime

Java Programming : Write a JAVA Program to find the Average and Sum of an Array.

Posted on:
tags: ,


     Write a JAVA Program to find the Average and Sum of an Array.
import java.io.*;
import java.util.*;
public class a16 {
   

     public static void main(String args[])throws IOException
                 {
                        Scanner br = new Scanner (System.in);
                        System.out.println("Enter the no. of elements");
                        int n = br.nextInt();

                             int a[]=new int[n];
                        int sum=0,i,avg;
                             System.out.println("Enter the elements");
                        for(i=0;i<n;i++)
                a[i] = br.nextInt();
                         for(i=0;i<n;i++)
                        {
                        sum=sum+a[i];
                        }
                        System.out.println("the sum is"+sum);
                        avg=sum/n;
                        System.out.println("the avg is"+avg);
                        }
                        }
OUTPUT:
Enter the no. of elements
4
Enter the elements
4
5
6
7
the sum is22
the avg is5

Java Programming : Write a JAVA Program to print the Fibonacci Series .

Posted on:
tags: ,


   Write a JAVA Program to print the Fibonacci Series .
import java.io.*;
public class fibo {
     public static void main(String argc[]) throws IOException
    {
        fibonacci ob1 = new fibonacci();
        ob1.input();
        ob1.call();
     
    }


}
class fibonacci
{
     public int n,a,b,c,i;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    void input() throws IOException
    {
        System.out.println("ENTER THE NUMBER :: ");
        n = Integer.parseInt(br.readLine());

    }
    void call()
    {
        a = 0;
        b = 1;
        System.out.println("THE  FIBONACCI SERIES IS ::");
        System.out.print(a+" , ");
       System.out.print(b);
        for(i = 2; i <= n; i++)
        {
            c = a + b;
            a = b;
             b = c;
            
             System.out.print(" , "+c);

        }

    }

}
OUTPUT:
ENTER THE NUMBER ::
7
THE  FIBONACCI SERIES IS ::
0 , 1 , 1 , 2 , 3 , 5 , 8 , 13

System Administration : Duties of Administrator

Posted on:
tags: ,

    

Duties of Administrator


1.        Installing and Configuring Servers

2.        Installing and Configuring Application Software

3.        Creating and Maintaining User Accounts

4.        Backing Up and Restoring Files

5.        Monitoring and Tuning Performance

6.        Configuring a Secure System

7.        Using Tools to Monitor Security

8.        Personal Computer Networking and Integration

9.        Train technicians, students, and scientists in the operations of the computer system s/w and h/w

10.     Coordinate computer system h/w and s/w maintenance agreements with vendors.

Java Programming: Write a JAVA Program Sorting Strings

Posted on:
tags: ,

     

Write a JAVA Program Sorting Strings
import java.io.*;

public class a14 {


        public static void main(String args[])throws IOException
        {
      BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                System.out.println("Enter the no. of strings");

                String s=br.readLine();
                int n=Integer.parseInt(s);

                String str[]=new String[n];
                System.out.println("Enter the strings");
                for(int i=0;i<n;i++)
                str[i]=br.readLine();

                for(int i=0;i<n-1;i++)
                {
                        for(int j=0;j<n-i-1;j++)
                        {
                                if(((str[j]).compareTo(str[j+1]))>0)
                                {
                                        String t=str[j];
                                        str[j]=str[j+1];
                                        str[j+1]=t;
                                }
                        }
                 }
                  System.out.println("sorted string is");
                for(int i=0;i<n;i++)
                System.out.println( str[i]);
        }
 }
OUTPUT:
Enter the no. of strings
4
Enter the strings
s
d
ff
gg
sorted string is
d
ff
gg
s

Java Programming : Write a JAVA Program Sorting Numbers

Posted on:
tags: ,


    Write a JAVA Program Sorting Numbers
import java.io.*;
import java.util.*;
public class a13 {




        public static void main(String args[])throws IOException
        {
                 Scanner br = new Scanner (System.in);
                 System.out.println("Enter the no. of elements");

                 int n = br.nextInt();
                 int arr[]=new int[n];
                System.out.println("Enter the elements");
                for(int i=0;i<n;i++)
                arr[i] = br.nextInt();

                for(int i=0;i<n;i++)
                {
                        for(int j=0;j<n-1;j++)
                        {
                                if(arr[j]>arr[j+1]){
                                                     int temp=arr[j];
                                                     arr[j]=arr[j+1];
                                                     arr[j+1]=temp;
                                         }
                        }
                 }System.out.println("\nsorted array");
                 System.out.println("\n");
                for(int i=0;i<n;i++)

                System.out.println(arr[i]);
        }
 }
OUTPUT:
Enter the no. of elements
4
Enter the elements
2
1
53
22

sorted array
1
2
22
53
< >