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/README.md b/README.md index ae51dc5..1adc530 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ 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? +* If you invoke a value method and don’t do anything with the returned result, the result is simply discarded and has no effect on the program + ## 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..c891d94 --- /dev/null +++ b/src/Lab006.java @@ -0,0 +1,56 @@ +/** + * Ethan Jauernig 10/5/23 + * Lab006(int n, int m): + * This is the constructor method of the class Lab006. + * It takes two parameters: n and m, which are both of type int. + * + * + * isDivisible(): + * This is an instance method of the class Lab006. + * It does not take any parameters. + * It returns a boolean value that indicates whether the instance variable n is evenly divisible by the instance variable m. + * + * + * main(String[] args): + * This is the main method of the class Lab006. + * It takes one parameter: args, which is an array of type String. + * + * + * nextInt(): This is a method of the class Scanner. It takes no parameters. + * + * Parameters: + * n,m,args + */ + + + +import java.util.Scanner; + + public class Lab006 { + + private int n; + private int m; + + public Lab006(int n, int m) { + this.n = n; + this.m = m; + } + + public boolean isDivisible() { + return n % m == 0; + } + + public static void main(String[] args) { + Scanner in = new Scanner(System.in); + System.out.print("Enter two integers: "); + int n = in.nextInt(); + int m = in.nextInt(); + in.close(); + + Lab006 lab = new Lab006(n, m); + boolean result = lab.isDivisible(); + + System.out.println("Is " + n + " evenly divisible by " + m + "? " + result); + } + } +