-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathone_dimensionl_option.java
More file actions
122 lines (120 loc) · 4.55 KB
/
Copy pathone_dimensionl_option.java
File metadata and controls
122 lines (120 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package array;
import java.util.Scanner;
public class one_dimensionl_option {
public static void main(String[] args) {
int i,n = 0,op,j,temp,m;
int sn;
boolean b = false;
int arr[] = new int[100];
Scanner objin = new Scanner(System.in);
do {
System.out.println(" 1. Input ");
System.out.println(" 2. Output ");
System.out.println(" 3. Search ");
System.out.println(" 4. Update ");
System.out.println(" 5. Delete ");
System.out.println(" 6. Insert ");
System.out.println(" 7. Sort ");
System.out.println(" 8. Appent ");
System.out.println(" 9. Exit ");
System.out.print("Please Select One Option :");
op = objin.nextInt();
switch (op) {
case 1 -> {
System.out.print("Input Element of Array :");
n = objin.nextInt();
for(i=0;i<n;i++){
System.out.print("Input Array["+i+"] :");
arr[i] = objin.nextInt();
}
}
case 2 -> {
for(i=0;i<n;i++){
System.out.println("Input Array["+i+"] :"+arr[i]);
}
}
case 3 -> {
System.out.print("Input Array to Search :");
sn = objin.nextInt();
for(i=0;i<n;i++){
if(sn==arr[i]){
System.out.println("Input Array["+i+"] :"+arr[i]);
b=true;
}
}
if(b==false){
System.out.println("Search is not found ...!");
}
}
case 4 -> {
System.out.print("Input Array to Search for Update :");
sn = objin.nextInt();
for(i=0;i<n;i++){
if(arr[i]==sn){
System.out.println("Input Array["+i+"] :");
arr[i] = objin.nextInt();
b=true;
}
}
if(b==false){
System.out.println("Search is not found ...!");
}
}
case 5 -> {
System.out.print("Input Array to Search :");
sn = objin.nextInt();
for(i=0;i<n;i++){
if(arr[i]==sn){
for(j=i;j<n;j++){
arr[j] = arr[j++];
}
n=n-1;
}
}
if(b==false){
System.out.println("Search is not found ...!");
}
}
case 6 -> {
System.out.print("Input Array to Search :");
sn = objin.nextInt();
for(i=0;i<n;i++){
if(arr[i]==sn){
for(j=i;j<n;j--){
arr[j] = arr[j+1];
}
n=n+1;
System.out.print("Input Array["+i+"] :");
arr[i] = objin.nextInt();
b=true;
}
}
if(b==false){
System.out.println("Search is not found ...!");
}
}
case 7 -> {
for(i=0;i<n;i++){
for(j=i+1;j<n;j++){
if(arr[i]<arr[j]){
temp=arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
}
}
System.out.println("Sort is Completed ..!");
}
case 8 -> {
System.out.print("Input Element of Array :");
m = objin.nextInt();
for(i=n;i<n+m;i++){
System.out.print("Input Array["+i+"] :");
arr[i] = objin.nextInt();
}
System.out.println("Appent Successful ..!");
}
}
} while (op!=9);
}
}