Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

write a program that takes in two integer numbers x and y. print the output acco

ID: 3922333 • Letter: W

Question

write a program that takes in two integer numbers x and y. print the output according to the following rules:
prints "div" if either number is evenly divisible by the other prints "even" if both numbers are even prints "ybugger" if x is less than y prints nothing- ie no output if ALK the above is true
write program in java write a program that takes in two integer numbers x and y. print the output according to the following rules:
prints "div" if either number is evenly divisible by the other prints "even" if both numbers are even prints "ybugger" if x is less than y prints nothing- ie no output if ALK the above is true
write program in java write a program that takes in two integer numbers x and y. print the output according to the following rules:
prints "div" if either number is evenly divisible by the other prints "even" if both numbers are even prints "ybugger" if x is less than y prints nothing- ie no output if ALK the above is true
write program in java

Explanation / Answer

Hi, Please find my code.

import java.util.Scanner;

public class IntegerTest {

   public static void main(String[] args) {

      

       // scanner object to take user input

       Scanner sc = new Scanner(System.in);

       // taking integers from user

       System.out.print("Enter first integer: ");

       int x = sc.nextInt();

       System.out.print("Enter second integer: ");

       int y = sc.nextInt();

      

       //x%y==0 : means x is divisible by y

       // (x/y)%2)==0 : means x is evenly divisible by y

       if((x%y==0 && ((x/y)%2)==0) || (y%x==0 && ((y/x)%2)==0)){

           System.out.println("div");

       }

      

       // both numbers are even

       if(x%2==0 && y%2==0)

           System.out.println("even");

      

       // if x is lesser than y

       if(x < y)

           System.out.println("ybugger");

      

      

   }

}

/*

Sample Output:

Enter first integer: 4

Enter second integer: 8

div

even

ybugger

Enter first integer: 5

Enter second integer: 4

Enter first integer: 4

Enter second integer: 6

even

ybugger

*/