diff --git a/README.md b/README.md index ae51dc5..e083291 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? - + * **Nothing happens, aside from the method being computed and then the result is not stored.** ## 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..97f2ee4 --- /dev/null +++ b/src/Lab006.java @@ -0,0 +1,59 @@ +import java.util.Scanner; + +/** + * + * @author Cassandra Portlock + * + * @since Version 1 + * + */ + +public class Lab006 { + + int n; + int m; + + /** + * Assigns values to the Class instance variables. + * + * @param x is the first number entered + * @param y is the number x will be divided by + */ + public Lab006(int x, int y){ + n = x; + m = y; + } + + /** + * Tests whether the variables are divisible evenly or not. + * + * @param x the integer to test + * @return true if the modulus of x = 0 + */ + public boolean isDivisible(int x){ + return x % 2 == 0; + } + + /** + * runs the program + * + * @param args holds the arguments for the program. + */ + public static void main(String[] args){ + Scanner s = new Scanner(System.in); + + System.out.print("Enter a number: "); + int number1 = Integer.parseInt(s.nextLine()); + System.out.print("Enter a second number: "); + int number2 = Integer.parseInt(s.nextLine()); + System.out.println(); + + Lab006 division =new Lab006(number1, number2); + + if (division.isDivisible(number1/number2)) { + System.out.printf("%s is divisible by %s evenly.", number1, number2); + } else { + System.out.printf("%s is not divisible by %s evenly.", number1, number2); + } + } +} \ No newline at end of file