Results 1 to 9 of 9
  1. #1
    scaler2000 is offline Member
    Join Date
    Dec 2010
    Location
    malta
    Posts
    4
    Rep Power
    0

    Default doesnt stop compiling

    hi all i am new here and was wondering if anyone of you could help me
    i am a collage studednt and am using bluej, i typed out this code and it doesnt want to stop compiling
    it is a simple prog to turn a number from integer to binary
    (i havent finished it yet)
    any help would be apreciated :)


    import java.util.Scanner;
    public class inttobin
    {
    public static void main (String[] args)
    {
    Scanner sc = new Scanner (System.in);
    System.out.println ("please enter a num you want turned to binary");
    int num = sc.nextInt();
    int i = 8;
    while (i > 0)
    {
    i--;
    int x = (num%(Mathpow(2,i))));
    String bin = String.valueOf(x);
    }
    }
    }
    Last edited by scaler2000; 12-19-2010 at 12:31 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,051
    Blog Entries
    7
    Rep Power
    23

    Default

    Quote Originally Posted by scaler2000 View Post
    hi all i am new here and was wondering if anyone of you could help me
    i am a collage studednt and am using bluej, i typed out this code and it doesnt want to stop compiling
    If your compiler 'hangs' it is broken. I'm (almost) sure something else is happening.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    scaler2000 is offline Member
    Join Date
    Dec 2010
    Location
    malta
    Posts
    4
    Rep Power
    0

    Default

    it works with all my other programs its just this one so i dont think it is broken

    thanks anyway

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,051
    Blog Entries
    7
    Rep Power
    23

    Default

    Quote Originally Posted by scaler2000 View Post
    it works with all my other programs its just this one so i dont think it is broken
    If a compiler fails to compile at least one program (showing errors or not) it is broken, but, as I wrote, I guess something else is going on here but we can't tell you what because you didn't show us your code.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  5. #5
    scaler2000 is offline Member
    Join Date
    Dec 2010
    Location
    malta
    Posts
    4
    Rep Power
    0

    Default

    import java.util.Scanner;
    public class inttobin
    {
    public static void main (String[] args)
    {
    Scanner sc = new Scanner (System.in);
    System.out.println ("please enter a num you want turned to binary");
    int num = sc.nextInt();
    String bin = "";
    int i = 8;
    while (i > 0)
    {
    i--;
    int x = (num%(Mathpow(2,i))));
    bin = String.valueOf(x);
    System.out.println(bin);
    }
    }
    }

  6. #6
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,051
    Blog Entries
    7
    Rep Power
    23

    Default

    Quote Originally Posted by scaler2000 View Post
    import java.util.Scanner;
    public class inttobin
    {
    public static void main (String[] args)
    {
    Scanner sc = new Scanner (System.in);
    System.out.println ("please enter a num you want turned to binary");
    int num = sc.nextInt();
    String bin = "";
    int i = 8;
    while (i > 0)
    {
    i--;
    int x = (num%(Mathpow(2,i))));
    bin = String.valueOf(x);
    System.out.println(bin);
    }
    }
    }
    Right, my compiler signals a few errors (Mathpow isn't defined and the parenteses on that line don't match); what does your compiler do? Does it protest about something or does it just 'hang'?

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  7. #7
    scaler2000 is offline Member
    Join Date
    Dec 2010
    Location
    malta
    Posts
    4
    Rep Power
    0

    Default

    no it just hangs

    regards

  8. #8
    Shashwat is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default

    can anybody help me? i am new here!! Sry scaler...4 posting my querry here... i have to make a simple java program....which should be quite big(lengthwise) and useful; If any1 can help me out of it!! then i will be very glad!! visit my profile and message me or mail me at handcy.shashwat@gmail.com!!
    Thank You!!

  9. #9
    Shashwat is offline Member
    Join Date
    Jan 2011
    Posts
    4
    Rep Power
    0

    Default

    btw scaler can you help me by telling me abt ur program...a bit

Similar Threads

  1. Replies: 7
    Last Post: 09-28-2010, 12:17 AM
  2. The outer loop doesnt stop running
    By Bulelakes in forum JDBC
    Replies: 16
    Last Post: 08-23-2010, 09:42 AM
  3. Use stop button to stop moving (stop timers) on JPanel
    By mneskovic in forum New To Java
    Replies: 3
    Last Post: 07-23-2010, 12:50 PM
  4. Dll Call doesnt work
    By INFACT in forum New To Java
    Replies: 1
    Last Post: 10-04-2009, 09:31 PM
  5. My program doesnt display anything
    By Bojevnik in forum AWT / Swing
    Replies: 2
    Last Post: 10-19-2007, 02:50 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •