castajiz_2 35 Posting Whiz

This is a solution on how you could solve you problem, I m again working in java a little bit so I m trying to get the syntax to my brain so I hope that people won't get mad for posting the solution...

public class Solution
{

    public static void main(String[] args) 
    {
      Scanner sc=new Scanner(System.in);
        String concat="";
        String input = sc.nextLine();
        char [] array=input.toCharArray();
        for(int i =0;i<array.length;i++)
        {
            int z=(int)array[i];
            String binary=decToBin(z);
            concat=concat+CheckNumbersOfDigits(binary);
            concat+="-";

        }
       out.println(removeLastChar(concat));
    }
    private static String CheckNumbersOfDigits(String digit) 
    {

        int diglen=digit.length();
        int add_dig=8-diglen;
        for(int i=0;i<add_dig;i++)
        {
            digit="0"+digit;
        }
        return digit;
    }
    public static String decToBin(int dec) 
    {
        if (dec == 0) {
            return "0"; // special case
        }

        final StringBuilder result = new StringBuilder();
        int current = dec;

        while (current != 0) {
            result.append(current & 0x1);
            current = current >> 1;
        }

        return result.reverse().toString();
    }
    private static String removeLastChar(String str) {
        return str.substring(0,str.length()-1);
    }

 }
castajiz_2 35 Posting Whiz
for (;n!=0;n/=10)
{
  do something till n==0;
}

Is this something like a while loop or do while loop or some kind of imitation?

Dawood Ahmad commented: for loop +0
castajiz_2 35 Posting Whiz

I forgot to tell write to lines of code in the timer1_Tick EVENT
after

 Ontimee.Invoke();
 counter = 0;
 timer1.Enabled = false;

In this way you will be able to reuse your app...

castajiz_2 35 Posting Whiz
namespace WindowsFormsApplication1
{
     public delegate void EventHandler();

    public partial class Form1 : Form
    {
        int counter = 0;
        public static  event EventHandler Ontimee;
        public Form1()
        {
            InitializeComponent();
        }



        private void button1_Click()
        {
          MessageBox.Show("Your work");

        }



        private void timer1_Tick(object sender, EventArgs e)
        {
            counter++;
            if (counter == 3) 
            {
                Ontimee += new EventHandler(button1_Click);
                Ontimee.Invoke();
            }

        }

        private void button1_MouseHover(object sender, EventArgs e)
        {

            timer1.Enabled = true;

        }
    }
}

I think that this is what you want.Have a look at events Click Here, Good luck