formatting output
This commit is contained in:
@@ -16,8 +16,8 @@ public class AlgorithmTester{
|
|||||||
static int input;
|
static int input;
|
||||||
static boolean quit = false;
|
static boolean quit = false;
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
System.out.println("SORTING ALGORITHM TESTER\n");
|
|
||||||
while(!quit){
|
while(!quit){
|
||||||
|
System.out.println("\nSORTING ALGORITHM TESTER");
|
||||||
System.out.println("Please select an option:");
|
System.out.println("Please select an option:");
|
||||||
System.out.println("1) Make a file of random numbers");
|
System.out.println("1) Make a file of random numbers");
|
||||||
System.out.println("2) Sort a file of random numbers");
|
System.out.println("2) Sort a file of random numbers");
|
||||||
@@ -62,7 +62,7 @@ public class AlgorithmTester{
|
|||||||
int min;
|
int min;
|
||||||
int max;
|
int max;
|
||||||
try{
|
try{
|
||||||
System.out.print("Please enter a file name: ");
|
System.out.print("\nPlease enter a file name: ");
|
||||||
filename = sc.next();
|
filename = sc.next();
|
||||||
System.out.println("How many random numbers?");
|
System.out.println("How many random numbers?");
|
||||||
count = sc.nextInt();
|
count = sc.nextInt();
|
||||||
@@ -83,13 +83,13 @@ public class AlgorithmTester{
|
|||||||
boolean bubble=false, selection=false, insertion=false;
|
boolean bubble=false, selection=false, insertion=false;
|
||||||
boolean quick=false, counting=false; //radix=false, merge=false;
|
boolean quick=false, counting=false; //radix=false, merge=false;
|
||||||
boolean ready=false;
|
boolean ready=false;
|
||||||
boolean print = false;
|
boolean print=false;
|
||||||
System.out.print("Please enter file name: ");
|
System.out.print("\nPlease enter file name: ");
|
||||||
filename = sc.next();
|
filename = sc.next();
|
||||||
while(!ready){
|
while(!ready){
|
||||||
try{
|
try{
|
||||||
System.out.println("Enter the number of the algorithms you wish to use.");
|
System.out.println("\nEnter the number of an algorithm you wish to use.");
|
||||||
System.out.println("Enter 0 to start sorting.");
|
System.out.println("Enter the number again to deselect an algorithm.");
|
||||||
if(bubble){
|
if(bubble){
|
||||||
System.out.print("*");
|
System.out.print("*");
|
||||||
}
|
}
|
||||||
@@ -110,6 +110,7 @@ public class AlgorithmTester{
|
|||||||
System.out.print("*");
|
System.out.print("*");
|
||||||
}
|
}
|
||||||
System.out.println("5) quick sort");
|
System.out.println("5) quick sort");
|
||||||
|
System.out.println("Enter 0 to continue when all desired algorithms have been selected.");
|
||||||
input = sc.nextInt();
|
input = sc.nextInt();
|
||||||
switch(input){
|
switch(input){
|
||||||
case 1 -> bubble=!bubble;
|
case 1 -> bubble=!bubble;
|
||||||
@@ -125,7 +126,7 @@ public class AlgorithmTester{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
System.out.println("Print sorted list?");
|
System.out.println("\nPrint sorted list?");
|
||||||
System.out.println("1) Yes");
|
System.out.println("1) Yes");
|
||||||
System.out.println("2) No");
|
System.out.println("2) No");
|
||||||
input = sc.nextInt();
|
input = sc.nextInt();
|
||||||
@@ -164,10 +165,9 @@ public class AlgorithmTester{
|
|||||||
System.out.print(i+" ");
|
System.out.print(i+" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("");
|
System.out.println("\n"+e.getSortType()+" sort took:");
|
||||||
System.out.println(e.getSortType()+" sort took:");
|
|
||||||
System.out.println(e.getComparisonsUsed()+" comparisons");
|
System.out.println(e.getComparisonsUsed()+" comparisons");
|
||||||
System.out.println(e.getTimeUsed().toMillis()+" milliseconds\n");
|
System.out.println(e.getTimeUsed().toMillis()+" milliseconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user