diff --git a/.idea/misc.xml b/.idea/misc.xml index 7464918..f34ceba 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/Lab006.java b/src/Lab006.java new file mode 100644 index 0000000..4632a6a --- /dev/null +++ b/src/Lab006.java @@ -0,0 +1,48 @@ +/** + * Lab006 class. + * This class prompts the user for two integers and checks if the first integer is evenly divisible by the second integer. + * + * Justin Hart + * @version 1.0 + */ + + + + +import java.util.Scanner; + +public class Lab006 { + int n; // instance variable n + int m; // instance variable m + + // constructor + public Lab006(int n, int m) { + this.n = n; + this.m = m; + } + + // method to check divisibility + public boolean isDivisible() { + return (m != 0 && n % m == 0); + } + + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.println("Enter the first integer:"); + int n = scanner.nextInt(); + + System.out.println("Enter the second integer:"); + int m = scanner.nextInt(); + + Lab006 obj = new Lab006(n, m); + boolean result = obj.isDivisible(); + + System.out.println("Is " + n + " evenly divisible by " + m + "? " + result); + } +} + + + + +