Computer Science, asked by chandrika429, 7 months ago

Dr. CooCoo just loves the number 7 and considers it lucky. She loves it so much that she has a formula to understand if a pair of numbers are lucky are not. If any or both of the numbers are 7, then the pair is lucky If the sum of the numbers is 7, then the pair is lucky If the absolute difference of the 2 numbers is 7, then the pair is lucky Write a function Met that takes as parameters 2 integers and prints Lucky! if the pair is lucky. Otherwise it prints Not Lucky! The Met method has to be inside a Solution class. Please check the code editor for the ideal method definition. Use the System.out.println() statement for printing. Example Input: 1 6 Output: Lucky! Example Input: -9 -16 Output: Lucky! Example Input: 7 95 Output: Lucky! Example Input: 28 57 Output: Not Lucky!

Answers

Answered by ıtʑFᴇᴇʟɓᴇãᴛ
0

tex

huge

bf

She loves it so much that she has a formula to understand if a pair of numbers are lucky are not. If any or both of the numbers are 7, then the pair is lucky If the sum of the numbers is 7, then the pair is lucky If the absolute difference of the 2 numbers is 7, then the pair is lucky Write a function Met that takes as parameters 2 integers and prints Lucky! if the pair is lucky. Otherwise it prints Not Lucky! The Met method has to be inside a Solution class. Please check the code editor for the ideal method definition. Use the System.out.println() statement for printing.

<tex>

Answered by dreamrob
2

Program in Java:

import java.util.*;

public class Solution

{

   static void Met(int a, int b)

   {

       if(a==7 || b==7 || (a+b)==7 || Math.abs(a-b)==7)

       {

           System.out.println("Lucky!");

       }

       else

       {

           System.out.println("Not Lucky!");

       }

   }

   public static void main(String args[])

   {

       Scanner Sc = new Scanner(System.in);

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

       int a = Sc.nextInt();

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

       int b = Sc.nextInt();

       Met(a, b);

   }

}

Output 1:

Enter first number : 1

Enter second number : 6

Lucky!

Output 2:

Enter first number : -9

Enter second number : -16

Lucky!

Output 3:

Enter first number : 7

Enter second number : 95

Lucky!

Output 4:

Enter first number : 28

Enter second number : 57

Not Lucky!

Similar questions