Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /***
- * @uthor Benicio Liu
- * @version 10/18/2019
- * This
- */
- public class Aquapodz2 {
- /**
- *
- * @param args argument is stated
- */
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- String cmd = "";
- String subCMD = "";
- // this is the user arrays
- double[] input = new double[15];
- double[] input1 = new double[15];
- double[] input3 = new double[15];
- // sum of A, B and C all equal to 0
- double sumA = 0;
- double sumB = 0;
- double sumC = 0;
- // azu, bub, cry is initialized
- int azu = 0;
- int azuviewCounter = 0;
- int bub = 0;
- int bubCounter = 0;
- int cry = 0;
- int cryCounter = 0;
- // Average of A,B, and C initialized
- double avgA = 0;
- double avgB = 0;
- double avgC = 0;
- int countFail;
- int aC = 0;
- int aB = 0;
- // Maximum of A, B, C also states the sum of the failures
- double maxA;
- double maxB;
- double maxC;
- double sumFail = 0;
- System.out.println("Please enter a command:");
- cmd = sc.nextLine();
- while (!cmd.equals("x")) {
- if (cmd.equals("a")) {
- for (int i = azuviewCounter, h = 1; i < 15 && h <= 3; i++, h++) {
- System.out.println("Enter number " + h + ":");
- input[i] = sc.nextDouble();
- if ((input[i] < -6.0) || (input[i] > 12.3)) {
- azu = azu + 1;
- sumFail += input[i];
- }
- azuviewCounter += 1;
- }
- sc.nextLine();
- } else if (cmd.equals("A")) {
- System.out.println("Enter a subcommand:");
- subCMD = sc.nextLine();
- if ("f".equals(subCMD)) {
- System.out.printf("%.2f\n", input[0]);
- } else if ("z".equals(subCMD)) {
- System.out.printf("%.2f\n", input[azuviewCounter - 1]);
- } else if ("a".equals(subCMD)) {
- for (int k = 0; k < azuviewCounter; k++) {
- if (k > 0) {
- System.out.print(",");
- }
- System.out.printf("%.2f", input[k]);
- }
- System.out.println();
- } else if ("s".equals(subCMD)) {
- for (int j = 0; j < azuviewCounter; j++) {
- sumA += input[j];
- }
- System.out.printf("%.3f\n", sumA);
- } else if ("v".equals(subCMD)) {
- for (int d = 0; d < azuviewCounter; d++) {
- sumA += input[d];
- avgA = sumA / azuviewCounter;
- }
- System.out.printf("%.5f\n", avgA);
- } else if ("n".equals(subCMD)) {
- System.out.println(azuviewCounter);
- } else if ("m".equals(subCMD)) {
- maxA = input[0];
- for (int p = 0; p < azuviewCounter; p++) {
- if (maxA < input[p]) {
- maxA = input[p];
- }
- }
- System.out.printf("%.1f\n", maxA);
- } else {
- System.out.println(subCMD + " is an invalid subcommand.");
- }
- } else if (cmd.equals("b")) {
- for (int i = bubCounter, j = 1; i < 15 && j <= 3; i++, j++) {
- System.out.println("Enter number " + j + ":");
- input1[i] = sc.nextDouble();
- aB = aB + 1;
- if ((input1[i] < -6.0) || (input1[i] > 12.3)) {
- bub = bub + 1;
- sumFail += input1[i];
- }
- bubCounter += 1;
- }
- sc.nextLine();
- } else if (cmd.equals("B")) {
- System.out.println("Enter a subcommand:");
- subCMD = sc.nextLine();
- if (subCMD.equals("f")) {
- System.out.printf("%.2f\n", input1[0]);
- } else if (subCMD.equals("z")) {
- System.out.printf("%.2f\n", input1[bubCounter - 1]);
- } else if (subCMD.equals("a")) {
- for (int k = 0; k < bubCounter; k++) {
- if (k > 0) {
- System.out.print(",");
- }
- System.out.printf("%.2f", input1[k]);
- }
- System.out.println();
- } else if (subCMD.equals("s")) {
- for (int j = 0; j < bubCounter; j++) {
- sumB += input1[j];
- }
- System.out.printf("%.3f\n", sumB);
- } else if (subCMD.equals("v")) {
- for (int e = 0; e < bubCounter; e++) {
- sumB += input1[e];
- avgB = sumB / bubCounter;
- }
- System.out.printf("%.5f\n", avgB);
- } else if (subCMD.equals("n")) {
- System.out.println(azuviewCounter);
- } else if (subCMD.equals("m")) {
- maxB = input1[0];
- for (int l = 0; l < bubCounter; l++) {
- if (maxB < input1[l]) {
- maxB = input1[l];
- }
- }
- System.out.printf("%.1f\n", maxB);
- } else {
- System.out.println(subCMD + " is an invalid subcommand.");
- }
- } else if (cmd.equals("c")) {
- for (int i = cryCounter, j = 1; i < 15 && j <= 3; i++, j++) {
- System.out.println("Enter number " + j + ":");
- input3[i] = sc.nextDouble();
- aC = aC + 1;
- if ((input3[i] < -6.0) || (input3[i] > 12.3)) {
- cry = cry + 1;
- sumFail += input3[i];
- }
- cryCounter += 1;
- }
- sc.nextLine();
- } else if (cmd.equals("C")) {
- System.out.println("Enter a subcommand:");
- subCMD = sc.nextLine();
- if (subCMD.equals("f")) {
- System.out.printf("%.2f\n", input3[0]);
- } else if (subCMD.equals("z")) {
- System.out.printf("%.2f\n", input3[cryCounter - 1]);
- } else if (subCMD.equals("a")) {
- for (int k = 0; k < cryCounter; k++) {
- if (k > 0) {
- System.out.print(",");
- }
- System.out.printf("%.2f", input3[k]);
- }
- System.out.println();
- } else if (subCMD.equals("s")) {
- for (int j = 0; j < cryCounter; j++) {
- sumC += input3[j];
- }
- System.out.printf("%.3f\n", sumC);
- } else if (subCMD.equals("v")) {
- for (int v = 0; v < cryCounter; v++) {
- sumC += input3[v];
- avgC = sumC / cryCounter;
- }
- System.out.printf("%.5f\n", avgC);
- } else if (subCMD.equals("n")) {
- System.out.println(cryCounter);
- } else if (subCMD.equals("m")) {
- maxC = input3[0];
- for (int u = 0; u < cryCounter; u++) {
- if (maxC < input3[u]) {
- maxC = input3[u];
- }
- }
- System.out.printf("%.1f\n", maxC);
- } else {
- System.out.println(subCMD + " is an invalid subcommand.");
- }
- } else if (cmd.equals("f")) {
- System.out.println("Azuview failures:" + " " + azu);
- System.out.println("Bublon failures:" + " " + bub);
- System.out.println("Cryztal failures:" + " " + cry);
- } else if (cmd.equals("v")) {
- if (azu + bub + cry == 0) {
- System.out.println("0");
- } else {
- System.out.printf("%.3f\n", sumFail / (azu + bub + cry));
- }
- } else if (cmd.equals("n")) {
- countFail = azuviewCounter + bubCounter + cryCounter;
- System.out.println(countFail);
- } else {
- System.out.println(cmd + " " + "is not valid.");
- }
- System.out.println("Please enter a command:");
- cmd = sc.nextLine();
- }
- System.out.println("Program ended");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement