-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
68 lines (54 loc) · 1.67 KB
/
Copy pathMain.java
File metadata and controls
68 lines (54 loc) · 1.67 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
package sorting;
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
int n, choice;
String ch;
final String yes="y";
Scanner input = new Scanner(System.in);
System.out.println("Welcome to Sorting-Profile ...");
do {
System.out.print("\nhow many numbers you want to sort : ");
n = input.nextInt();
System.out.print("enter numbers : ");
int[] arr = new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i] = input.nextInt();
}
System.out.println("******************************************************");
System.out.println(
" 1.Press 1 for Bubble Sort. \n 2.Press 2 for Selection Sort. \n 3.Press 3 for Merge Sort. \n 4.Press 4 for Quick Sort. ");
System.out.println("******************************************************");
choice = input.nextInt();
System.out.println();
switch (choice) {
case 1:
System.out.println("you chose Bubble Sort !");
BubbleSort.bubbleSort(arr);
BubbleSort.printArray(arr);
break;
case 2:
System.out.println("you chose Selection Sort !");
SelectionSort.sort(arr);
SelectionSort.printArray(arr);
break;
case 3:
System.out.println("you chose Merge Sort !");
MergeSort.sort(arr, 0, arr.length - 1);
MergeSort.printArray(arr);
break;
case 4:
System.out.println("you chose Quick Sort !");
QuickSort.sort(arr, 0, arr.length - 1);
QuickSort.printArray(arr);
break;
default:
System.out.println("you entered wrong choice !");
break;
}
System.out.print("\nDo you want to continue y/n : ");
ch=input.next();
}while(ch.equals(yes));
System.out.println("\nThank you for using this software ... \n Have a nice day !");
}
}