Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
59 changes: 59 additions & 0 deletions src/Lab006.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
}