Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.16 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /***
  4. * @uthor Benicio Liu
  5. * @version 10/18/2019
  6. * This
  7. */
  8.  
  9. public class Aquapodz2 {
  10. /**
  11. *
  12. * @param args argument is stated
  13. */
  14. public static void main(String[] args) {
  15. Scanner sc = new Scanner(System.in);
  16. String cmd = "";
  17. String subCMD = "";
  18.  
  19. // this is the user arrays
  20. double[] input = new double[15];
  21. double[] input1 = new double[15];
  22. double[] input3 = new double[15];
  23. // sum of A, B and C all equal to 0
  24. double sumA = 0;
  25. double sumB = 0;
  26. double sumC = 0;
  27. // azu, bub, cry is initialized
  28. int azu = 0;
  29. int azuviewCounter = 0;
  30. int bub = 0;
  31. int bubCounter = 0;
  32. int cry = 0;
  33. int cryCounter = 0;
  34.  
  35. // Average of A,B, and C initialized
  36. double avgA = 0;
  37. double avgB = 0;
  38. double avgC = 0;
  39.  
  40. int countFail;
  41. int aC = 0;
  42. int aB = 0;
  43. // Maximum of A, B, C also states the sum of the failures
  44. double maxA;
  45. double maxB;
  46. double maxC;
  47. double sumFail = 0;
  48.  
  49. System.out.println("Please enter a command:");
  50. cmd = sc.nextLine();
  51. while (!cmd.equals("x")) {
  52.  
  53.  
  54. if (cmd.equals("a")) {
  55. for (int i = azuviewCounter, h = 1; i < 15 && h <= 3; i++, h++) {
  56. System.out.println("Enter number " + h + ":");
  57. input[i] = sc.nextDouble();
  58. if ((input[i] < -6.0) || (input[i] > 12.3)) {
  59. azu = azu + 1;
  60. sumFail += input[i];
  61. }
  62. azuviewCounter += 1;
  63. }
  64. sc.nextLine();
  65. } else if (cmd.equals("A")) {
  66. System.out.println("Enter a subcommand:");
  67.  
  68. subCMD = sc.nextLine();
  69.  
  70. if ("f".equals(subCMD)) {
  71.  
  72. System.out.printf("%.2f\n", input[0]);
  73.  
  74. } else if ("z".equals(subCMD)) {
  75.  
  76. System.out.printf("%.2f\n", input[azuviewCounter - 1]);
  77.  
  78. } else if ("a".equals(subCMD)) {
  79. for (int k = 0; k < azuviewCounter; k++) {
  80. if (k > 0) {
  81. System.out.print(",");
  82. }
  83. System.out.printf("%.2f", input[k]);
  84. }
  85. System.out.println();
  86. } else if ("s".equals(subCMD)) {
  87. for (int j = 0; j < azuviewCounter; j++) {
  88. sumA += input[j];
  89. }
  90. System.out.printf("%.3f\n", sumA);
  91. } else if ("v".equals(subCMD)) {
  92. for (int d = 0; d < azuviewCounter; d++) {
  93. sumA += input[d];
  94. avgA = sumA / azuviewCounter;
  95. }
  96. System.out.printf("%.5f\n", avgA);
  97. } else if ("n".equals(subCMD)) {
  98. System.out.println(azuviewCounter);
  99. } else if ("m".equals(subCMD)) {
  100. maxA = input[0];
  101. for (int p = 0; p < azuviewCounter; p++) {
  102. if (maxA < input[p]) {
  103. maxA = input[p];
  104. }
  105. }
  106. System.out.printf("%.1f\n", maxA);
  107. } else {
  108. System.out.println(subCMD + " is an invalid subcommand.");
  109. }
  110. } else if (cmd.equals("b")) {
  111. for (int i = bubCounter, j = 1; i < 15 && j <= 3; i++, j++) {
  112. System.out.println("Enter number " + j + ":");
  113. input1[i] = sc.nextDouble();
  114. aB = aB + 1;
  115. if ((input1[i] < -6.0) || (input1[i] > 12.3)) {
  116. bub = bub + 1;
  117. sumFail += input1[i];
  118. }
  119. bubCounter += 1;
  120. }
  121. sc.nextLine();
  122. } else if (cmd.equals("B")) {
  123.  
  124. System.out.println("Enter a subcommand:");
  125. subCMD = sc.nextLine();
  126.  
  127. if (subCMD.equals("f")) {
  128. System.out.printf("%.2f\n", input1[0]);
  129. } else if (subCMD.equals("z")) {
  130.  
  131. System.out.printf("%.2f\n", input1[bubCounter - 1]);
  132. } else if (subCMD.equals("a")) {
  133. for (int k = 0; k < bubCounter; k++) {
  134. if (k > 0) {
  135. System.out.print(",");
  136. }
  137. System.out.printf("%.2f", input1[k]);
  138. }
  139. System.out.println();
  140. } else if (subCMD.equals("s")) {
  141.  
  142. for (int j = 0; j < bubCounter; j++) {
  143. sumB += input1[j];
  144. }
  145. System.out.printf("%.3f\n", sumB);
  146. } else if (subCMD.equals("v")) {
  147.  
  148. for (int e = 0; e < bubCounter; e++) {
  149. sumB += input1[e];
  150.  
  151. avgB = sumB / bubCounter;
  152. }
  153. System.out.printf("%.5f\n", avgB);
  154. } else if (subCMD.equals("n")) {
  155.  
  156. System.out.println(azuviewCounter);
  157. } else if (subCMD.equals("m")) {
  158.  
  159. maxB = input1[0];
  160.  
  161. for (int l = 0; l < bubCounter; l++) {
  162. if (maxB < input1[l]) {
  163. maxB = input1[l];
  164. }
  165. }
  166. System.out.printf("%.1f\n", maxB);
  167. } else {
  168.  
  169. System.out.println(subCMD + " is an invalid subcommand.");
  170. }
  171. } else if (cmd.equals("c")) {
  172. for (int i = cryCounter, j = 1; i < 15 && j <= 3; i++, j++) {
  173.  
  174. System.out.println("Enter number " + j + ":");
  175. input3[i] = sc.nextDouble();
  176.  
  177. aC = aC + 1;
  178. if ((input3[i] < -6.0) || (input3[i] > 12.3)) {
  179. cry = cry + 1;
  180.  
  181. sumFail += input3[i];
  182. }
  183. cryCounter += 1;
  184. }
  185. sc.nextLine();
  186.  
  187. } else if (cmd.equals("C")) {
  188. System.out.println("Enter a subcommand:");
  189.  
  190. subCMD = sc.nextLine();
  191. if (subCMD.equals("f")) {
  192. System.out.printf("%.2f\n", input3[0]);
  193.  
  194. } else if (subCMD.equals("z")) {
  195.  
  196. System.out.printf("%.2f\n", input3[cryCounter - 1]);
  197. } else if (subCMD.equals("a")) {
  198. for (int k = 0; k < cryCounter; k++) {
  199. if (k > 0) {
  200. System.out.print(",");
  201. }
  202. System.out.printf("%.2f", input3[k]);
  203. }
  204. System.out.println();
  205. } else if (subCMD.equals("s")) {
  206.  
  207. for (int j = 0; j < cryCounter; j++) {
  208. sumC += input3[j];
  209. }
  210. System.out.printf("%.3f\n", sumC);
  211. } else if (subCMD.equals("v")) {
  212. for (int v = 0; v < cryCounter; v++) {
  213. sumC += input3[v];
  214. avgC = sumC / cryCounter;
  215. }
  216. System.out.printf("%.5f\n", avgC);
  217. } else if (subCMD.equals("n")) {
  218. System.out.println(cryCounter);
  219. } else if (subCMD.equals("m")) {
  220.  
  221. maxC = input3[0];
  222. for (int u = 0; u < cryCounter; u++) {
  223. if (maxC < input3[u]) {
  224. maxC = input3[u];
  225. }
  226. }
  227. System.out.printf("%.1f\n", maxC);
  228. } else {
  229. System.out.println(subCMD + " is an invalid subcommand.");
  230. }
  231. } else if (cmd.equals("f")) {
  232. System.out.println("Azuview failures:" + " " + azu);
  233. System.out.println("Bublon failures:" + " " + bub);
  234. System.out.println("Cryztal failures:" + " " + cry);
  235.  
  236. } else if (cmd.equals("v")) {
  237. if (azu + bub + cry == 0) {
  238. System.out.println("0");
  239. } else {
  240. System.out.printf("%.3f\n", sumFail / (azu + bub + cry));
  241. }
  242. } else if (cmd.equals("n")) {
  243. countFail = azuviewCounter + bubCounter + cryCounter;
  244. System.out.println(countFail);
  245. } else {
  246. System.out.println(cmd + " " + "is not valid.");
  247. }
  248. System.out.println("Please enter a command:");
  249. cmd = sc.nextLine();
  250. }
  251.  
  252. System.out.println("Program ended");
  253. }
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement