Search:

Type: Posts; User: Shambolic

Page 1 of 2 1 2

Search: Search took 0.48 seconds.

  1. Replies
    7
    Views
    1,162

    Re: Small Project

    Don't do people's assessed work for them! This chump doesn't deserve to pass his (or her) course.
  2. Replies
    1
    Views
    1,626

    Re: Error in Program for Game of Craps

    I would just remove the static modifier from all your methods. That should fix your error.

    However, there is a lot more wrong with your code. Consider your rollDie method. None of its
    local...
  3. Thread: movement

    by Shambolic
    Replies
    4
    Views
    771

    Re: movement

    It's probably got a remote control. If it doesn't work, try changing the batteries. Otherwise, you
    could just pick it up and move it around, making robot noises (like BZZZT, or VWEEE-OO) with your...
  4. Replies
    5
    Views
    8,278

    Re: Char cannot be dereferenced!! Please help

    .toString() is an instance method for Objects. You say your getPerson() method is returning
    a char; a char is a primitive data type, not an Object! Just compare the returned value directly
    to the...
  5. Replies
    7
    Views
    8,603

    Re: Base Conversion

    % is the "modulo" operator. For integers a and b, a % b is the remainder when a is divided by b. Some examples:

    8 % 3 = 2
    11 % 5 = 1
    n % 2 = 1 for n odd
    n % 2 = 0 for n even

    And so on......
  6. Replies
    2
    Views
    1,038

    Re: Need Urgent Help

    Nobody is going to do your assignment for you. If you try it yourself, and run into specific
    problems with parts of your code, we can then help you work out what you're doing wrong.
  7. Replies
    4
    Views
    6,924

    Re: for loop and while loop problems

    If you think about it, you can easily turn any for loop into a while loop.
    Consider the following:


    for(initialise; condition; increment)
    {
    //stuff
    }

    How can you write that as a while...
  8. Re: I can't find out what is wrong with my code. Please Help!

    Oh wait, now I see why what you're doing is wrong. For A, B, C to form a triangle, it has to be true that A+B>C, A+C>B and B+C>A. In other words, all three have to be true. The reason your program...
  9. Thread: need help

    by Shambolic
    Replies
    4
    Views
    983

    Re: need help

    James, the correct way to put code tags around your code is...

    [ code ]
    This is my code
    [ /code ]

    ...but without the spaces between the brackets and "code" or "/code".
  10. Replies
    4
    Views
    1,416

    Re: making my code a little better, if needed.

    There is nothing wrong with having multiple constructors in the same class. In fact, it's very common.

    It's hard to tell what you're trying to do, but if mainMethod should always use the same...
  11. Re: I can't find out what is wrong with my code. Please Help!

    You have written


    else if(A+C>C)

    when you intended


    else if(A+C>B)
  12. Replies
    3
    Views
    6,146

    Re: Question about my coin toss program

    It's amazing how walking away from a problem and coming back later can make such a difference!
    Just yesterday I spent ages trying to write a simple algorithm (in Mathematica, not Java), but couldn't...
  13. Replies
    3
    Views
    6,146

    Re: Question about my coin toss program

    Your question is not very clear. Are you having trouble working out how to calculate the percentage, how to display it, or both? Or do you mean something else?

    If there are N trials, and heads...
  14. Replies
    5
    Views
    639

    Re: Rounding screwed up?

    Lots of reasons! In fact you're probably likely to come across ints more often than floats. You just need to make sure you choose the right type of variable for what you want to do! :)
  15. Replies
    5
    Views
    1,239

    Re: Code not printing correctly

    Ah, good point jassi. A String can be compared to a StringBuffer using the String.contentEquals(StringBuffer) method; String.equals(Object) will always return false if the Object is not a String. ...
  16. Replies
    5
    Views
    1,239

    Re: Code not printing correctly

    Is the output from the following two lines what you expect it to be?


    System.out.println("palindrome: " + palindrome);
    System.out.println("numbers: " + numbers);


    I'm guessing it's not. ...
  17. Replies
    5
    Views
    639

    Re: Rounding screwed up?

    If it has a decimal point, then it's not an int!
    You need


    float whatever = Float.parseFloat(Sa);


    Also note the usual java convention that variables are in all lower case. Conventions like...
  18. [SOLVED] Re: theory behind testing each element of an array.

    Do you read through your code systematically? Pretend you are a dumb computer, reading every line literally and doing what it says. For example, in the code you have written, what is the purpose of...
  19. Thread: sorting

    by Shambolic
    Replies
    8
    Views
    1,545

    [SOLVED] Re: sorting

    I think the 'pass' variable is playing a useful role, but the boolean 'done' is not. Why not try:



    while(pass<entry.length-1)
    {
    //algorithm
    }
  20. Replies
    1
    Views
    854

    Re: Card and CardTest

    Your getDescription method has a String parameter called value, and this hides the instance variable value. You should probably set 'value' in the constructor, and remove the parameter from...
  21. Replies
    8
    Views
    770

    [SOLVED] Re: frame are exiting at the same time

    I believe calling System.exit terminates everything.
  22. [SOLVED] Re: How to Put Spaces in the Output of Passed Arguments?

    Just put spaces in explicitly:


    if(args.length <= 0)
    System.out.print("Hello World");
    else if (args.length > 0)
    {
    System.out.print("Hello");
    for (int i = 0; i < args.length;...
  23. Replies
    7
    Views
    665

    Re: annoying error.

    I think you just want currency to be a String i.e.


    String currency =UserInput.readString();
  24. Replies
    7
    Views
    665

    Re: annoying error.

    You are trying to create a variable called 'currency' which can hold an object of type Sterling, but it seems you haven't written a class called Sterling, hence the compiler error.
  25. Replies
    7
    Views
    4,163

    Re: Chessboard filling issue

    This is only a minor thing, but you can simply your if statement. Instead of...


    if ( (i % 2 == 0 && j % 2 == 0) || ( i % 2 == 1 && j % 2 == 1) )


    ...you can just write


    if((i+j)%2 ==...
Results 1 to 25 of 30
Page 1 of 2 1 2