diff --git a/.idea/misc.xml b/.idea/misc.xml index 7464918..4dd49c4 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,5 @@ - - + \ No newline at end of file diff --git a/README.md b/README.md index ae51dc5..6e74d0c 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ In this README.md, answer the following question: * What happens if you invoke a value method (i.e. a method that returns a result) and don't do anything with the returned result; that is, if you don't assign the returned result to a variable or use it as part of a larger expression? - +**The program executes properly, a value is returned, but nothing is done with it. Due to nothing being done with the value a warning is shown in the IDE.** ## PART 2 * Fork and clone this lab as you have done in all previous labs, and then complete the following: * Create a new **class** called **Lab006** diff --git a/src/Lab006.java b/src/Lab006.java new file mode 100644 index 0000000..746c745 --- /dev/null +++ b/src/Lab006.java @@ -0,0 +1,39 @@ +import java.util.Scanner; +/** + * @author Skyler + * Lab 006 assignment completed 10/25/23 + */ +public class Lab006 { + private int n; + private int m; + private static final Scanner input = new Scanner(System.in); + + /** + * Tests whether a digit is divisible by another + * @return true if n is evenly divisible by m, false if otherwise + */ + public boolean isDivisible(){ + return n % m == 0; + } + + /** + * Constructor method that assigns two input variables to instance variables + * @param n dividend input + * @param m divisor input + */ + public Lab006(int n, int m){ + this.n = n; + this.m = m; + } + + public static void main(String[] args) { + System.out.print("Please enter a dividend: "); + int x = Integer.parseInt(input.nextLine()); + + System.out.print("Please enter a divisor: "); + int y = Integer.parseInt(input.nextLine()); + + Lab006 lab = new Lab006(x,y); + System.out.println("Is " + x + " divisible by " + y + "?\n" + lab.isDivisible()); + } +}