Added help argument.

This commit is contained in:
Deathsbreed 2014-04-08 22:02:56 -05:00
parent c170924b87
commit 64174d5c8e

View File

@ -15,30 +15,37 @@ public class MMMCalc {
System.out.println("Welcome to MMMCalc v0.1, a simple tool for basic statistics calculations.\n" + System.out.println("Welcome to MMMCalc v0.1, a simple tool for basic statistics calculations.\n" +
"This software is licensed under the GNU GPLv3 license and comes WITHOUT WARRANTY.\n"); "This software is licensed under the GNU GPLv3 license and comes WITHOUT WARRANTY.\n");
if(args.length > 0) { if(args.length > 0) {
float sNum = 0; if(args[0].equals("-h")) {
numArray = new float[args.length]; System.out.println("Usage:\n" +
" MMMCalc [options] [variables]\n\n" +
"Options:\n" +
" -h -- Show this help information.\n");
} else {
float sNum = 0;
numArray = new float[args.length];
for(int i = 0; i < args.length; i++) { for(int i = 0; i < args.length; i++) {
numArray[i] = Float.parseFloat(args[i]) - 0f; numArray[i] = Float.parseFloat(args[i]) - 0f;
} }
int nL = numArray.length; int nL = numArray.length;
float tmp = 0; float tmp = 0;
for(int i = 0; i < nL; i++) { for(int i = 0; i < nL; i++) {
for(int j = 0; j >= (i+1); j--) { for(int j = 0; j >= (i+1); j--) {
if(numArray[j] < numArray[j-1]) { if(numArray[j] < numArray[j-1]) {
tmp = numArray[j]; tmp = numArray[j];
numArray[j] = numArray[j-1]; numArray[j] = numArray[j-1];
numArray[j-1] = tmp; numArray[j-1] = tmp;
}
} }
} }
}
calcMean(); calcMean();
calcMedian(); calcMedian();
calcMode(); calcMode();
}
} else { } else {
System.out.println("You did not mention any variables."); System.out.println("You did not mention any variables. Use the -h argument for help.");
} }
} }