diff --git a/lab9_CalebFontenot.zip b/lab9_CalebFontenot.zip new file mode 100644 index 0000000..3c81c7b Binary files /dev/null and b/lab9_CalebFontenot.zip differ diff --git a/lab9_CalebFontenot/MinimumOf4ConditionalOperator.html b/lab9_CalebFontenot/MinimumOf4ConditionalOperator.html new file mode 100644 index 0000000..555a547 --- /dev/null +++ b/lab9_CalebFontenot/MinimumOf4ConditionalOperator.html @@ -0,0 +1,70 @@ + + + +MinimumOf4ConditionalOperator.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4ConditionalOperator.java
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.calebfontenot.lab9_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author ASDV2
+ */
+public class MinimumOf4ConditionalOperator {
+
+    public static void main(String[] args)
+    {
+        Scanner scan = new Scanner(System.in);
+        while (true) {
+            System.out.println("Please enter 4 numbers to find the minimum of the 4: ");
+            int _1 = scan.nextInt();
+            int _2 = scan.nextInt();
+            int _3 = scan.nextInt();
+            int _4 = scan.nextInt();
+
+            System.out.println("minimum= "
+                    + ((_1 < _4)
+                            ? (_1 < _3)
+                                    ? (_1 < _2)
+                                            ? _1
+                                            : _2
+                                    : (_3 < _2)
+                                            ? _3
+                                            : _2
+                            : (_4 < _3)
+                                    ? (_4 < _2)
+                                            ? _4
+                                            : _2
+                                    : (_3 < _2)
+                                            ? _3
+                                            : _2)
+            );
+            scan.next();
+        }
+    }
+}
+
+
+ diff --git a/lab9_CalebFontenot/MinimumOf4DeMorgan.html b/lab9_CalebFontenot/MinimumOf4DeMorgan.html new file mode 100644 index 0000000..c6aca39 --- /dev/null +++ b/lab9_CalebFontenot/MinimumOf4DeMorgan.html @@ -0,0 +1,63 @@ + + + +MinimumOf4DeMorgan.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4DeMorgan.java
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.calebfontenot.lab9_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author ASDV2
+ */
+public class MinimumOf4DeMorgan {
+
+    public static void main(String[] args)
+    {
+        Scanner scan = new Scanner(System.in);
+        while (true) {
+            System.out.print("Please enter 4 numbers to find the minimum of the 4: ");
+            System.out.println("");
+            int _1 = scan.nextInt();
+            int _2 = scan.nextInt();
+            int _3 = scan.nextInt();
+            int _4 = scan.nextInt();
+
+            if (!(_1 > _4 || _1 > _3 || _1 > _2)) { // Is 1 the minimum?
+                System.out.println("minimum= " + _1);
+            } else if (!(_2 > _4 || _2 > _3 || _2 > _1)) { // Is 2 the minimum?
+                System.out.println("minimum= " + _2);
+            } else if (!(_3 > _4 || _3 > _2 || _3 > _1)) { // Is 3 the minimum?
+                System.out.println("minimum= " + _3);
+            } else { // All other conditions failed, _4 must be the minimum
+                System.out.println("minimum= " + _4);
+            }
+            scan.next();
+        }
+    }
+}
+
+
+ diff --git a/lab9_CalebFontenot/MinimumOf4NestedIfs.html b/lab9_CalebFontenot/MinimumOf4NestedIfs.html new file mode 100644 index 0000000..628315c --- /dev/null +++ b/lab9_CalebFontenot/MinimumOf4NestedIfs.html @@ -0,0 +1,84 @@ + + + +MinimumOf4NestedIfs.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4NestedIfs.java
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.calebfontenot.lab9_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author ASDV2
+ */
+public class MinimumOf4NestedIfs {
+
+    public static void main(String[] args) {
+        Scanner scan = new Scanner(System.in);
+        while (true) {
+            System.out.println("Please enter 4 numbers to find the minimum of the 4: ");
+            int _1 = scan.nextInt();
+            int _2 = scan.nextInt();
+            int _3 = scan.nextInt();
+            int _4 = scan.nextInt();
+
+            if (_1 < _4) {
+                if (_1 < _3) {
+                    if (_1 < _2) {
+                        System.out.println("minimum= " + _1);
+                    } else {
+                        System.out.println("minimum= " + _2);
+                    }
+                } else {
+                    if (_3 < _2) {
+                        System.out.println("minimum= " + _3);
+                    } else {
+                        System.out.println("minimum= " + _2);
+                    }
+                }
+            } else {
+                if (_4 < _3) {
+                    if (_4 < _2) {
+                        System.out.println("minimum= " + _4);
+                    } else {
+                        System.out.println("minimum= " + _2);
+                    }
+                } else {
+                    if (_3 < _2) {
+                        System.out.println("minumum= " + _3);
+                    } else {
+                        System.out.println("minimum= " + _2);
+                    }
+                }
+            }
+            
+            scan.next();
+        }
+
+    }
+
+}
+
+
+ diff --git a/lab9_CalebFontenot/MinimumOf4WithANDs.html b/lab9_CalebFontenot/MinimumOf4WithANDs.html new file mode 100644 index 0000000..b53c4e5 --- /dev/null +++ b/lab9_CalebFontenot/MinimumOf4WithANDs.html @@ -0,0 +1,63 @@ + + + +MinimumOf4WithANDs.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4WithANDs.java
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.calebfontenot.lab9_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author ASDV2
+ */
+public class MinimumOf4WithANDs {
+
+    public static void main(String[] args)
+    {
+        Scanner scan = new Scanner(System.in);
+        while (true) {
+            System.out.print("Please enter 4 numbers to find the minimum of the 4: ");
+            int _1 = scan.nextInt();
+            int _2 = scan.nextInt();
+            int _3 = scan.nextInt();
+            int _4 = scan.nextInt();
+            System.out.println("");
+            
+            if (_1 <= _4 && _1 <= _3 && _1 <= _2) { // Is 1 the minimum?
+                System.out.println("minimum= " + _1);
+            } else if (_2 <= _4 && _2 <= _3 && _2 <= _1) { // Is 2 the minimum?
+                System.out.println("minimum= " + _2);
+            } else if (_3 <= _4 && _3 <= _2 && _3 <= _1) { // Is 3 the minimum?
+                System.out.println("minimum= " + _3);
+            } else { // All other conditions failed, _4 must be the minimum
+                System.out.println("minimum= " + _4);
+            }
+            scan.next();
+        }
+    }
+}
+
+
+ diff --git a/lab9_CalebFontenot/lab9_CalebFontenot.docx b/lab9_CalebFontenot/lab9_CalebFontenot.docx index 636c1fb..11df4ba 100644 Binary files a/lab9_CalebFontenot/lab9_CalebFontenot.docx and b/lab9_CalebFontenot/lab9_CalebFontenot.docx differ diff --git a/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4ConditionalOperator.java b/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4ConditionalOperator.java index 2ef7a77..6a0efb1 100644 --- a/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4ConditionalOperator.java +++ b/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4ConditionalOperator.java @@ -13,31 +13,34 @@ import java.util.Scanner; */ public class MinimumOf4ConditionalOperator { - public static void main(String[] args) { + public static void main(String[] args) + { Scanner scan = new Scanner(System.in); + while (true) { + System.out.println("Please enter 4 numbers to find the minimum of the 4: "); + int _1 = scan.nextInt(); + int _2 = scan.nextInt(); + int _3 = scan.nextInt(); + int _4 = scan.nextInt(); - System.out.println("Please enter 4 numbers to find the minimum of the 4: "); - int _1 = scan.nextInt(); - int _2 = scan.nextInt(); - int _3 = scan.nextInt(); - int _4 = scan.nextInt(); - - System.out.println("minimum= " + - ((_1 < _4) - ? (_1 < _3) - ? (_1 < _2) - ? _1 - : _2 - : (_3 < _2) - ? _3 - : _2 - : (_4 < _3) - ? (_4 < _2) - ? _4 - : _2 - : (_3 < _2) - ? _3 - : _2) - ); + System.out.println("minimum= " + + ((_1 < _4) + ? (_1 < _3) + ? (_1 < _2) + ? _1 + : _2 + : (_3 < _2) + ? _3 + : _2 + : (_4 < _3) + ? (_4 < _2) + ? _4 + : _2 + : (_3 < _2) + ? _3 + : _2) + ); + scan.next(); + } } } diff --git a/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4DeMorgan.java b/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4DeMorgan.java index 1177448..61afc97 100644 --- a/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4DeMorgan.java +++ b/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4DeMorgan.java @@ -13,26 +13,27 @@ import java.util.Scanner; */ public class MinimumOf4DeMorgan { - public static void main(String[] args) { + public static void main(String[] args) + { Scanner scan = new Scanner(System.in); + while (true) { + System.out.print("Please enter 4 numbers to find the minimum of the 4: "); + System.out.println(""); + int _1 = scan.nextInt(); + int _2 = scan.nextInt(); + int _3 = scan.nextInt(); + int _4 = scan.nextInt(); - System.out.println("Please enter 4 numbers to find the minimum of the 4: "); - int _1 = scan.nextInt(); - int _2 = scan.nextInt(); - int _3 = scan.nextInt(); - int _4 = scan.nextInt(); - - if (! (_1 > _4 || _1 > _3 || _1 > _2)) { // Is 1 the minimum? - System.out.println("minimum= " + _1); - } - else if (! (_2 > _4 || _2 > _3 || _2 > _1)) { // Is 2 the minimum? - System.out.println("minimum= " + _2); - } - else if (! (_3 > _4 || _3 > _2 || _3 > _1)) { // Is 3 the minimum? - System.out.println("minimum= " + _3); - } - else { // All other conditions failed, _4 must be the minimum - System.out.println("minimum= " + _4); + if (!(_1 > _4 || _1 > _3 || _1 > _2)) { // Is 1 the minimum? + System.out.println("minimum= " + _1); + } else if (!(_2 > _4 || _2 > _3 || _2 > _1)) { // Is 2 the minimum? + System.out.println("minimum= " + _2); + } else if (!(_3 > _4 || _3 > _2 || _3 > _1)) { // Is 3 the minimum? + System.out.println("minimum= " + _3); + } else { // All other conditions failed, _4 must be the minimum + System.out.println("minimum= " + _4); + } + scan.next(); } } } diff --git a/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4WithANDs.java b/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4WithANDs.java index e7b631d..09ce2d3 100644 --- a/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4WithANDs.java +++ b/lab9_CalebFontenot/src/main/java/com/calebfontenot/lab9_calebfontenot/MinimumOf4WithANDs.java @@ -13,42 +13,27 @@ import java.util.Scanner; */ public class MinimumOf4WithANDs { - public static void main(String[] args) { + public static void main(String[] args) + { Scanner scan = new Scanner(System.in); - - System.out.println("Please enter 4 numbers to find the minimum of the 4: "); - int _1 = 4; //scan.nextInt(); - int _2 = 3; //scan.nextInt(); - int _3 = 2; //scan.nextInt(); - int _4 = 1; //scan.nextInt(); -/* - if (_1 < _2) { // Is x less than y? - if (_1 < _3) { // Is x less than z? - //System.out.println("x is less than z!"); + while (true) { + System.out.print("Please enter 4 numbers to find the minimum of the 4: "); + int _1 = scan.nextInt(); + int _2 = scan.nextInt(); + int _3 = scan.nextInt(); + int _4 = scan.nextInt(); + System.out.println(""); + + if (_1 <= _4 && _1 <= _3 && _1 <= _2) { // Is 1 the minimum? System.out.println("minimum= " + _1); - } else { - //System.out.println("z is less than x!"); + } else if (_2 <= _4 && _2 <= _3 && _2 <= _1) { // Is 2 the minimum? + System.out.println("minimum= " + _2); + } else if (_3 <= _4 && _3 <= _2 && _3 <= _1) { // Is 3 the minimum? System.out.println("minimum= " + _3); + } else { // All other conditions failed, _4 must be the minimum + System.out.println("minimum= " + _4); } - } else if (_2 < _3) { // Is y less than z? - //System.out.println("y is less than z!"); - System.out.println("minimum= " + _2); - } else { - //System.out.println("z is less than y!"); - System.out.println("minimum= " + _3); - } - */ - if (_1 < _4 && _1 < _3 && _1 < _2) { // Is 1 the minimum? - System.out.println("minimum= " + _1); - } - else if (_2 < _4 && _2 < _3 && _2 < _1) { // Is 2 the minimum? - System.out.println("minimum= " + _2); - } - else if (_3 < _4 && _3 < _2 && _3 < _1) { // Is 3 the minimum? - System.out.println("minimum= " + _3); - } - else { // All other conditions failed, _4 must be the minimum - System.out.println("minimum= " + _4); + scan.next(); } } }