From a13b99068a85e0186f6614a8788e65fdd4c68b11 Mon Sep 17 00:00:00 2001 From: francoPalacios Date: Fri, 20 Oct 2023 18:05:59 -0700 Subject: [PATCH] this program tells you whether two number are divisible --- .idea/misc.xml | 2 +- src/Lab006.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/Lab006.java diff --git a/.idea/misc.xml b/.idea/misc.xml index 7464918..16168ca 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/Lab006.java b/src/Lab006.java new file mode 100644 index 0000000..ecdbbb4 --- /dev/null +++ b/src/Lab006.java @@ -0,0 +1,42 @@ +import java.util.Scanner; + +/**this is a program to tell whether two numbers are evenly disible.**/ +public class Lab006 { + + int n; + int m; + + /**here is the constructor assigning the instance variable**/ + public Lab006(int n, int m){ + this.n =n; + this.m =m; + + } + + /**the method returning whether or not two numbers are divisible**/ + public boolean isDivisible(){ + if(n%m==0){ + return true; + }else + return false; + + } +/**main method requesting user input and executing the isDivisible method**/ + public static void main(String[] args){ + Scanner input = new Scanner(System.in); + System.out.println("enter first number"); + int a = input.nextInt(); + System.out.println("input second number"); + int b = input.nextInt(); + + Lab006 obj = new Lab006(a, b); + boolean divisible = obj.isDivisible(); + + if(divisible) { + System.out.println("yes the numbers are divisible"); + }else{ + System.out.println("no the numbers are not divisible"); + } + } + +}