Problem With the Question Lucky Four

Question link: LUCKFOUR Problem - CodeChef

Scanner sc = new Scanner(System.in);
int taker = sc.nextInt();
String tester = String.valueOf(taker);
int counter = 0;

for (int i = 0; i < tester.length();i++)
{
if (tester.charAt(i) == ‘4’)
{
counter++;
}
else
continue;
}
System.out.println(counter);

That’s my code, the code seems to work in eclipse but after I upload it onto CodeChef, its wrong. Anyone know whats wrong with my code?

Please either copy-and-paste all of your code and format it using “Preformatted Text” (</>) or link to the failing submission. Thanks :slight_smile:

Since you’ve only posted a snippet of your full code, it’s hard to know for sure, but you don’t seem to be dealing with multiple testcases.

Sorry about that. Here is the link to the failing submission: CodeChef: Practical coding for everyone

And would you be able to further explain that?

The problem gives some example input and output. Given the output:

5
447474
228
6664
40
81

the output should be:

4
0
1
1
0

What is the output from your program with the given input?