diff options
Diffstat (limited to 'src/Q9/Number.java')
| -rw-r--r-- | src/Q9/Number.java | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/Q9/Number.java b/src/Q9/Number.java index 7092e26..cce45f3 100644 --- a/src/Q9/Number.java +++ b/src/Q9/Number.java @@ -1,20 +1,53 @@ +/** + * Assignment 1, COMP268 Class: Number.java + * + * @description Provides static methods for operating on numeric values. + * @author: mo khan Student ID: 3431709 + * @date May 8, 2019 + * @version 1.0 + */ package Q9; import java.util.ArrayList; public class Number { + /** + * Checks to see if a number is divisible by 5. + * + * @param n the number to check for divisibility + * @return true if the number is evenly divisible by 5 + */ public static boolean isDivisibleBy5(int n) { return isDivisibleBy(n, 5); } + /** + * Checks to see if a number is divisible by 7 + * + * @param n the number to check for divisibility + * @return true if the number is evenly divisible by 7 + */ public static boolean isDivisibleBy7(int n) { return isDivisibleBy(n, 7); } + /** + * Checks if a number is odd + * + * @param n the number to check + * @return true if the number is an odd number. + */ public static boolean isOdd(int n) { return !isDivisibleBy(n, 2); } + /** + * Checks if a number is prime. This is naive implementation of the prime number check that will + * blow the stack for any sufficiently large number. + * + * @param n the number to check + * @return true if the number is a prime number + */ public static boolean isPrime(int n) { if (n <= 1) return false; @@ -23,10 +56,18 @@ public class Number { return true; } + /** + * Checks to see if a number is divisible by denominator + * + * @param n the number to check for divisibility + * @param denominator the number to see if n is evenly divisible by + * @return true if the number is evenly divisible by denominator + */ public static boolean isDivisibleBy(int n, int denominator) { return n % denominator == 0; } + /** @return a list of strings for each number between 0 and 113 */ public static ArrayList<String> iterate() { ArrayList<String> items = new ArrayList<String>(); ArrayList<String> row = new ArrayList<String>(); |
