Array Operations In Java


 Array Operations


write a java program to perform array operations like insert data delete data search data display data,write a java program to perform different array operations like insert data delete data search data display data

import java.util.Scanner;

class ArrayOperations{

static int max=50;

double a[]=new double[max];

static int fre=0;

Scanner scan=new Scanner(System.in);

void insert(){

if(fre==max)

System.out.println("Array is Full....");

else

{

System.out.print("\n\nEnter Insert Value : ");

double in=scan.nextDouble();

a[fre]=in;

fre++;

display();

}

}

void delete(){

System.out.print("\n\nEnter Delete Position Value : ");

double in=scan.nextDouble();

int f=1,temp=0;

for(int i=0;i<=fre;i++){

if(in==i+1 && f==1){

fre--;

f=0;

temp++;

}

a[i]=a[temp];

temp++;

}

if(f==1)

System.out.println("\n\nValue Not Delete...");

else

display();

}

void search(){

System.out.print("\n\nEnter Search Value : ");

double in=scan.nextDouble();

for(int i=0;i<=fre;i++)

if(in==a[i]){

System.out.println("\nValue is Found at "+(i+1)+" Palce...");

return;

}

System.out.println("\nValue is not Found...");

}

void display(){

System.out.print("\n\nDispaly... ");

for(int i=0;i<fre;i++)

System.out.print(a[i]+"-->");

}

}

class Q6{

public static void main(String args[]){

ArrayOperations ao=new ArrayOperations();

int c=0;

while(c!=5){

System.out.print("\n\nSelection Opertion  :\n1.Insert  2.Delete  3.Search  4.Display  5.Quit\nEnter Selection :");

c=ao.scan.nextInt();

switch(c){

case 1 : ao.insert(); break;

case 2 : if(ao.fre!=0) ao.delete(); else System.out.println("Deletion Not work plz Insert Value..."); break;

case 3 : ao.search(); break;

case 4 : ao.display(); break;

case 5 : System.out.println("Quit....."); break;

default : System.out.println("Invaild....");

}

}

}

}

Concept of polygon absolute in computer graphics

Number operations in java

Comment your views on this Article :)


Thank you for visiting my blog :)


No comments

Comment your views on this article

Powered by Blogger.