urgent, please help

This line can be simplified

if((((count-sample)/val)-2*((count-sample)/val))>=80){

Compare it to x-2x >=80, -x >=80. In this case I assume x is negative so it becomes (-x)-2*(-x) >=80, -x >=80.

If I see these lines in my code

}

{

I start to look for mistakes. Ctrl-T is a very good shortcut. Try it in your code.