From bee6ed76879ce025067220ad176fa9a592315ab6 Mon Sep 17 00:00:00 2001 From: jojov Date: Sat, 28 Oct 2023 21:35:11 -0700 Subject: [PATCH] Finished Lab006 Joseph Verdin --- .idea/misc.xml | 2 +- README.md | 2 ++ src/Lab006.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/Lab006.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 7464918..69ace3f 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..cf1ec3e 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? +## Answer: +* What happens if you invoke a value method and don't do anything with the returned result is the code runs but the value isn't stored or used it is pretty much ignored. ## 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..11ae7d0 --- /dev/null +++ b/src/Lab006.java @@ -0,0 +1,53 @@ +/** + * Author - Joseph Verdin + * Date - 10/28/23 + */ + +import java.util.Scanner; +public class Lab006 { + private int n; + private int m; + + /** + * Created constructor for class Lab006 that takes two ints and assigns them to the Lab 006 instance variables. + * @param n 1st integer + * @param m 2nd integer + */ + public Lab006(int n, int m) { + this.n = n; + this.m = m; + + } + + /** + * Checks if 1st int is able to be evenly divided by the 2nd int + * @return True if n can be evenly divided by m if not is false + */ + public boolean isDivisible() { + return n % m == 0; + } + + /** + * Main method that asks user for two integers and uses the isDivisible method to check if they can be evenly divided then prints the answer + * @param args no arguments + */ + public static void main(String[] args) { + Scanner scanner = new Scanner(System.in); + + System.out.println("Enter Integer 1: "); + int num1 = scanner.nextInt(); + System.out.println("Enter Integer 2: "); + int num2 = scanner.nextInt(); + + Lab006 Labobj = new Lab006(num1, num2); + + boolean result = Labobj.isDivisible(); + if (result) { + System.out.println(num1 + " Can be evenly divided by " + num2); + } else { + System.out.println(num1 + " Can not be evenly divided by " + num2); + } + + + } +}