diff --git a/lab7_CalebFontenot.zip b/lab7_CalebFontenot.zip new file mode 100644 index 0000000..db2bf1e Binary files /dev/null and b/lab7_CalebFontenot.zip differ diff --git a/lab7_CalebFontenot/And1.html b/lab7_CalebFontenot/And1.html new file mode 100644 index 0000000..bd509ce --- /dev/null +++ b/lab7_CalebFontenot/And1.html @@ -0,0 +1,57 @@ + + + +And1.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And1.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class And1 {
+    public static void main(String[] args)
+    {
+        System.out.print("please enter a number between 0 and 10: ");
+        int number = new Scanner(System.in).nextInt();
+        
+        /*
+        the &&is the AND operator which ANDs 2 operands
+        The ANDing evaluates to true if both of the operands of the AND are true
+        UNDERSTAND THIS AND &&, please
+        */
+        if ( number >= 0 && number <= 10 )
+            System.out.println("\nthank you for entering number " + number );
+        else
+            System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?");
+    }
+}
+
+
+ diff --git a/lab7_CalebFontenot/And2.html b/lab7_CalebFontenot/And2.html new file mode 100644 index 0000000..e38927a --- /dev/null +++ b/lab7_CalebFontenot/And2.html @@ -0,0 +1,65 @@ + + + +And2.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And2.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class And2 {
+    public static void main(String[] args)
+    {
+        // Create Scanner
+        Scanner input = new Scanner(System.in);
+        
+        // Setup vars
+        int number;
+        
+        // Prompt for input
+        System.out.print("Please enter a number that is divisable by 10 and greater than 100: ");
+        number = input.nextInt();
+        
+        // Compute
+        if ( number % 10 == 0 && number > 100)
+        {
+            System.out.println("Thanks for entering number " + number+ "!");
+        }
+            else
+        {
+            System.out.println(number + " is not fufilling the request!");
+        }
+            
+    }
+}
+
+
+ diff --git a/lab7_CalebFontenot/Bonus.html b/lab7_CalebFontenot/Bonus.html new file mode 100644 index 0000000..2270e5a --- /dev/null +++ b/lab7_CalebFontenot/Bonus.html @@ -0,0 +1,86 @@ + + + +Bonus.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Bonus.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+import java.text.NumberFormat;
+
+/**
+ *
+ * @author caleb
+ */
+public class Bonus {
+    public static void main(String[] args)
+    {
+        //Setup currency formatter
+        NumberFormat defaultFormat = NumberFormat.getCurrencyInstance();
+        // Create scanner
+        Scanner input = new Scanner(System.in);
+        
+        // Setup vars
+        String lastName,
+               firstName;
+        double thisYearsUnits,
+               lastYearsUnits,
+               bonus = 0;
+        
+        // Prompt for input
+        System.out.print("Enter last name: ");
+        lastName = input.nextLine();
+        System.out.print("Enter first name: ");
+        firstName = input.nextLine();
+        System.out.print("Enter this year's units: ");
+        thisYearsUnits = input.nextDouble();
+        System.out.print("Enter last year's units: ");
+        lastYearsUnits = input.nextDouble();
+        
+        // Compute!
+        if (thisYearsUnits > lastYearsUnits) {
+            if (1000 > thisYearsUnits) // If thisYearsUnits is less than 1000
+                bonus = 25;
+            else if (thisYearsUnits > 1000 && thisYearsUnits < 3000) // If thisYearsUnits is more than 1000, but less than 3000
+                bonus = 50;
+            else if (thisYearsUnits > 3000 && thisYearsUnits < 6000) // If thisYearsUnits is more than 3000, but less than 6000
+                bonus = 100;
+            else if (thisYearsUnits > 6000) // 6000 and up
+                bonus = 200;
+        }
+        
+        // Output
+        System.out.println("Employee Name: ");
+        System.out.println("\t"+ lastName + ", " + firstName);
+        System.out.println("Bonus is "+ defaultFormat.format(bonus));
+        
+    } 
+}
+
+
+ diff --git a/lab7_CalebFontenot/Debug1.html b/lab7_CalebFontenot/Debug1.html new file mode 100644 index 0000000..0510773 --- /dev/null +++ b/lab7_CalebFontenot/Debug1.html @@ -0,0 +1,45 @@ + + + +Debug1.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Debug1.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Debug1 {
+    public static void main(String[] args)
+    {
+        int i=1, j=2, k=3;
+        if (i < j && i < k && j < k)
+        {
+            System.out.println("i, j, and k are in increasing order");
+        }
+    }
+}
+
+
+ diff --git a/lab7_CalebFontenot/DivisionQuiz.html b/lab7_CalebFontenot/DivisionQuiz.html new file mode 100644 index 0000000..450071d --- /dev/null +++ b/lab7_CalebFontenot/DivisionQuiz.html @@ -0,0 +1,92 @@ + + + +DivisionQuiz.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/DivisionQuiz.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class DivisionQuiz {
+
+    public static void main(String[] args)
+    {
+        // Create scanner
+        Scanner input = new Scanner(System.in);
+        // Setup variables
+        int number1,
+                number2,
+                answerQuotient,
+                answerRemainder;
+        boolean cheatMode = false; // Used for debugging
+
+        while (true) {
+            // Get random numbers between 1-100
+            number1 = (int) (Math.random() * 100);
+            number2 = (int) (Math.random() * 100);
+
+            // If number1 < number2, flip them
+            if (number1 < number2) {
+                int tmp = number2;
+                number2 = number1;
+                number1 = tmp;
+            }
+
+            //Prompt
+            if (cheatMode == true) {
+                System.out.println("CHEAT MODE: the quotient of " + number1 + " / " + number2 + " is " + (number1 / number2));
+            }
+            System.out.print(" What is the quotient of " + number1 + " / " + number2 + "? ");
+            answerQuotient = input.nextInt();
+            if (cheatMode == true) {
+                System.out.println("CHEAT MODE: the remainder of " + number1 + " % " + number2 + " is " + (number1 % number2));
+            }
+            System.out.print(" What is the remainder of " + number1 + " / " + number2 + "? ");
+            answerRemainder = input.nextInt();
+
+            // Check if answers are correct
+            if ((number1 / number2) == answerQuotient) //Checks the quotient
+            {
+                System.out.println("You are correct about the quotient!");
+            } else {
+                System.out.println("You are wrong about the quotient.");
+                System.out.println("The quotient of " + number1 + " / " + number2 + " is " + (number1 / number2));
+            }
+            if ((number1 % number2) == answerRemainder) //Checks the remainder
+            {
+                System.out.println("You are correct about the remainder!");
+            } else {
+                System.out.println("You are wrong about the remainder.");
+                System.out.println("The remainder of " + number1 + " % " + number2 + " is " + (number1 % number2));
+            }
+        }
+    }
+}
+
+
+ diff --git a/lab7_CalebFontenot/Not1.html b/lab7_CalebFontenot/Not1.html new file mode 100644 index 0000000..be01736 --- /dev/null +++ b/lab7_CalebFontenot/Not1.html @@ -0,0 +1,63 @@ + + + +Not1.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Not1.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class Not1 {
+    public static void main(String[] args)
+    {
+        System.out.print("Please enter a number between 0 and 10: ");
+        int number = new Scanner(System.in).nextInt();
+        /* 
+        The ! is the NOT operator which reverses a boolean expression.
+        If the expression is true, the not makes it false and vice-versa.
+        
+        the || is the OR operator which ORs 2 operands
+        This is the equivalent AND1 by using OR and NOT
+        
+        1. The && is replaced by ||
+        2. The relational operators are reversed
+        3. There is a ! (NOT) outside the prenthesis
+        */
+        if ( ! (number < 0 || number > 10) )
+        {
+            System.out.println("\nThank you for entering number " + number + "!");
+        }
+        else {
+            System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?");
+        }
+    }
+   
+}
+
+
+ diff --git a/lab7_CalebFontenot/Not2.html b/lab7_CalebFontenot/Not2.html new file mode 100644 index 0000000..1ba4ed9 --- /dev/null +++ b/lab7_CalebFontenot/Not2.html @@ -0,0 +1,66 @@ + + + +Not2.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Not2.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class Not2 {
+    public static void main(String[] args)
+    {
+        // Create Scanner
+        Scanner input = new Scanner(System.in);
+        
+        // Setup vars
+        int number;
+        
+        // Prompt for input
+        System.out.print("Please enter a number that is divisable by 10 and greater than 100: ");
+        number = input.nextInt();
+        
+        // Compute
+        //if ( number % 10 == 0 && number > 100)
+        if ( ! (number % 10 != 0 || number < 100) ) 
+        {
+            System.out.println("Thanks for entering number " + number+ "!");
+        }
+            else
+        {
+            System.out.println(number + " is not fufilling the request!");
+        }
+            
+    }
+}
+
+
+ diff --git a/lab7_CalebFontenot/Or1.html b/lab7_CalebFontenot/Or1.html new file mode 100644 index 0000000..c665587 --- /dev/null +++ b/lab7_CalebFontenot/Or1.html @@ -0,0 +1,54 @@ + + + +Or1.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Or1.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class Or1 {
+    public static void main(String[] args)
+    {
+        System.out.println("Please enter a number less than 0 or greater than or equal to 1,000");
+        int number = new Scanner(System.in).nextInt();
+        
+        /*
+        The || is the OR operator which ORs 2 operands
+        The ORing evaluates to true if either of the operands of the OR is true
+        UNDERSTAND THIS OR || please
+        */
+        if (number < 0 || number >= 1000)
+            System.out.println("\nThank you for entering number " + number );
+        else
+            System.out.println("\n " + number + " is not fulfilling the request!");
+    }
+}
+
+
+ diff --git a/lab7_CalebFontenot/Or2.html b/lab7_CalebFontenot/Or2.html new file mode 100644 index 0000000..5065d36 --- /dev/null +++ b/lab7_CalebFontenot/Or2.html @@ -0,0 +1,61 @@ + + + +Or2.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Or2.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class Or2 {
+    public static void main(String[] args)
+    {
+        // Create scanner
+        Scanner input = new Scanner(System.in);
+        
+        // Define vars
+        int number;
+        
+        // Prompt for input
+        System.out.print("Please enter a number less than 0 or divisable by 3 or both: ");
+        number = input.nextInt();
+        
+        // Compute
+        if ( number % 3 == 0 || number < 0)
+        {
+            System.out.println("Thank you for entering number " + number);
+        }
+        else
+        {
+            System.out.println(number + " is not fufilling the request!");
+        }
+    }
+}
+
+
+ diff --git a/lab7_CalebFontenot/SubtractionQuiz.html b/lab7_CalebFontenot/SubtractionQuiz.html new file mode 100644 index 0000000..7bbbb3a --- /dev/null +++ b/lab7_CalebFontenot/SubtractionQuiz.html @@ -0,0 +1,70 @@ + + + +SubtractionQuiz.java + + + + +
/home/caleb/NetBeansProjects/ADSV Java/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/SubtractionQuiz.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package com.calebfontenot.lab7_calebfontenot;
+
+import java.util.Scanner;
+
+/**
+ *
+ * @author caleb
+ */
+public class SubtractionQuiz {
+    public static void main(String[] args)
+    {
+        // Create scanner outside of loop so we don't create it over and over again
+        Scanner input = new Scanner(System.in);
+        while(true) {
+        // 1. Generate two random single-digit integers
+        int number1 = (int)(Math.random() * 10);
+        int number2 = (int)(Math.random() * 10);
+        
+        // 2. If number < number2, swap number1 with number2
+        if (number1 < number2)
+        {
+            int temp = number1;
+            number1 = number2;
+            number2 = temp;
+        }
+        
+        // 3. Prompt the student to answer "what is number1 - number2?"
+        System.out.print("What is " + number1 + " - " + number2 + "? ");
+        int answer = input.nextInt();
+        
+        // 4. Grade the answer and display the result
+        if (number1 - number2 == answer)
+            System.out.println("You are correct!");
+        else
+        {
+            System.out.println("Your answer is wrong.");
+            System.out.println(number1 + " - " + number2 + "should be" + (number1 - number2));
+        }
+    }
+    }
+}
+
+
+ diff --git a/lab7_CalebFontenot/lab7_CalebFontenot.docx b/lab7_CalebFontenot/lab7_CalebFontenot.docx new file mode 100644 index 0000000..c3a0b9b Binary files /dev/null and b/lab7_CalebFontenot/lab7_CalebFontenot.docx differ diff --git a/lab7_CalebFontenot/lab7_CalebFontenot.zip b/lab7_CalebFontenot/lab7_CalebFontenot.zip new file mode 100644 index 0000000..cbddb2c Binary files /dev/null and b/lab7_CalebFontenot/lab7_CalebFontenot.zip differ diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And1.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And1.java index dadd818..d5d956e 100644 --- a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And1.java +++ b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And1.java @@ -4,6 +4,8 @@ */ package com.calebfontenot.lab7_calebfontenot; +import java.util.Scanner; + /** * * @author caleb @@ -11,7 +13,17 @@ package com.calebfontenot.lab7_calebfontenot; public class And1 { public static void main(String[] args) { - System.out.println("please enter a number between 0 and 10:"); + System.out.print("please enter a number between 0 and 10: "); + int number = new Scanner(System.in).nextInt(); + /* + the &&is the AND operator which ANDs 2 operands + The ANDing evaluates to true if both of the operands of the AND are true + UNDERSTAND THIS AND &&, please + */ + if ( number >= 0 && number <= 10 ) + System.out.println("\nthank you for entering number " + number ); + else + System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?"); } } diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And2.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And2.java new file mode 100644 index 0000000..ff85b45 --- /dev/null +++ b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/And2.java @@ -0,0 +1,37 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.calebfontenot.lab7_calebfontenot; + +import java.util.Scanner; + +/** + * + * @author caleb + */ +public class And2 { + public static void main(String[] args) + { + // Create Scanner + Scanner input = new Scanner(System.in); + + // Setup vars + int number; + + // Prompt for input + System.out.print("Please enter a number that is divisable by 10 and greater than 100: "); + number = input.nextInt(); + + // Compute + if ( number % 10 == 0 && number > 100) + { + System.out.println("Thanks for entering number " + number+ "!"); + } + else + { + System.out.println(number + " is not fufilling the request!"); + } + + } +} diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Bonus.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Bonus.java new file mode 100644 index 0000000..ffbc1c4 --- /dev/null +++ b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Bonus.java @@ -0,0 +1,57 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.calebfontenot.lab7_calebfontenot; + +import java.util.Scanner; +import java.text.NumberFormat; + +/** + * + * @author caleb + */ +public class Bonus { + public static void main(String[] args) + { + //Setup currency formatter + NumberFormat defaultFormat = NumberFormat.getCurrencyInstance(); + // Create scanner + Scanner input = new Scanner(System.in); + + // Setup vars + String lastName, + firstName; + double thisYearsUnits, + lastYearsUnits, + bonus = 0; + + // Prompt for input + System.out.print("Enter last name: "); + lastName = input.nextLine(); + System.out.print("Enter first name: "); + firstName = input.nextLine(); + System.out.print("Enter this year's units: "); + thisYearsUnits = input.nextDouble(); + System.out.print("Enter last year's units: "); + lastYearsUnits = input.nextDouble(); + + // Compute! + if (thisYearsUnits > lastYearsUnits) { + if (1000 > thisYearsUnits) // If thisYearsUnits is less than 1000 + bonus = 25; + else if (thisYearsUnits > 1000 && thisYearsUnits < 3000) // If thisYearsUnits is more than 1000, but less than 3000 + bonus = 50; + else if (thisYearsUnits > 3000 && thisYearsUnits < 6000) // If thisYearsUnits is more than 3000, but less than 6000 + bonus = 100; + else if (thisYearsUnits > 6000) // 6000 and up + bonus = 200; + } + + // Output + System.out.println("Employee Name: "); + System.out.println("\t"+ lastName + ", " + firstName); + System.out.println("Bonus is "+ defaultFormat.format(bonus)); + + } +} diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Debug1.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Debug1.java new file mode 100644 index 0000000..df08a66 --- /dev/null +++ b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Debug1.java @@ -0,0 +1,20 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.calebfontenot.lab7_calebfontenot; + +/** + * + * @author caleb + */ +public class Debug1 { + public static void main(String[] args) + { + int i=1, j=2, k=3; + if (i < j && i < k && j < k) + { + System.out.println("i, j, and k are in increasing order"); + } + } +} diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Lab7_CalebFontenot.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Lab7_CalebFontenot.java deleted file mode 100644 index c422514..0000000 --- a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Lab7_CalebFontenot.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license - * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template - */ - -package com.calebfontenot.lab7_calebfontenot; - -/** - * - * @author caleb - */ -public class Lab7_CalebFontenot { - - public static void main(String[] args) { - System.out.println("Hello World!"); - } -} diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Not1.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Not1.java new file mode 100644 index 0000000..292bbed --- /dev/null +++ b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Not1.java @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.calebfontenot.lab7_calebfontenot; + +import java.util.Scanner; + +/** + * + * @author caleb + */ +public class Not1 { + public static void main(String[] args) + { + System.out.print("Please enter a number between 0 and 10: "); + int number = new Scanner(System.in).nextInt(); + /* + The ! is the NOT operator which reverses a boolean expression. + If the expression is true, the not makes it false and vice-versa. + + the || is the OR operator which ORs 2 operands + This is the equivalent AND1 by using OR and NOT + + 1. The && is replaced by || + 2. The relational operators are reversed + 3. There is a ! (NOT) outside the prenthesis + */ + if ( ! (number < 0 || number > 10) ) + { + System.out.println("\nThank you for entering number " + number + "!"); + } + else { + System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?"); + } + } + +} diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Not2.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Not2.java new file mode 100644 index 0000000..552b902 --- /dev/null +++ b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Not2.java @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.calebfontenot.lab7_calebfontenot; + +import java.util.Scanner; + +/** + * + * @author caleb + */ +public class Not2 { + public static void main(String[] args) + { + // Create Scanner + Scanner input = new Scanner(System.in); + + // Setup vars + int number; + + // Prompt for input + System.out.print("Please enter a number that is divisable by 10 and greater than 100: "); + number = input.nextInt(); + + // Compute + //if ( number % 10 == 0 && number > 100) + if ( ! (number % 10 != 0 || number < 100) ) + { + System.out.println("Thanks for entering number " + number+ "!"); + } + else + { + System.out.println(number + " is not fufilling the request!"); + } + + } +} diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Or1.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Or1.java new file mode 100644 index 0000000..ab677d5 --- /dev/null +++ b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Or1.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.calebfontenot.lab7_calebfontenot; + +import java.util.Scanner; + +/** + * + * @author caleb + */ +public class Or1 { + public static void main(String[] args) + { + System.out.println("Please enter a number less than 0 or greater than or equal to 1,000"); + int number = new Scanner(System.in).nextInt(); + + /* + The || is the OR operator which ORs 2 operands + The ORing evaluates to true if either of the operands of the OR is true + UNDERSTAND THIS OR || please + */ + if (number < 0 || number >= 1000) + System.out.println("\nThank you for entering number " + number ); + else + System.out.println("\n " + number + " is not fulfilling the request!"); + } +} diff --git a/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Or2.java b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Or2.java new file mode 100644 index 0000000..2c2106b --- /dev/null +++ b/lab7_CalebFontenot/src/main/java/com/calebfontenot/lab7_calebfontenot/Or2.java @@ -0,0 +1,36 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.calebfontenot.lab7_calebfontenot; + +import java.util.Scanner; + +/** + * + * @author caleb + */ +public class Or2 { + public static void main(String[] args) + { + // Create scanner + Scanner input = new Scanner(System.in); + + // Define vars + int number; + + // Prompt for input + System.out.print("Please enter a number less than 0 or divisable by 3 or both: "); + number = input.nextInt(); + + // Compute + if ( number % 3 == 0 || number < 0) + { + System.out.println("Thank you for entering number " + number); + } + else + { + System.out.println(number + " is not fufilling the request!"); + } + } +}