From 2b971592f4a394c0b3ba2e11c6529e3f81780f8e Mon Sep 17 00:00:00 2001 From: Ayush Mandal <66141678+code4oryou@users.noreply.github.com> Date: Sat, 1 Oct 2022 12:25:42 +0530 Subject: [PATCH] chore(Java) : add nearly lucky number --- algorithms/Java/Maths/nearlyLuckyNumberCF.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 algorithms/Java/Maths/nearlyLuckyNumberCF.java diff --git a/algorithms/Java/Maths/nearlyLuckyNumberCF.java b/algorithms/Java/Maths/nearlyLuckyNumberCF.java new file mode 100644 index 00000000..5f87eb6c --- /dev/null +++ b/algorithms/Java/Maths/nearlyLuckyNumberCF.java @@ -0,0 +1,18 @@ +import java.util.*; +public class nearlyLuckyNumberCF { + public static void main(String args[]){ + Scanner in = new Scanner(System.in); + long n = in.nextLong(); + int count = 0; + while(n > 0){ + if(n % 10 == 4 || n % 10 == 7){ + count++; + } + n = n/10; + } + if(count == 7 || count == 4) + System.out.print("YES"); + else + System.out.print("NO"); + } +}