Search:

Type: Posts; User: Norm

Search: Search took 0.10 seconds.

  1. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    The toString() method was for debugging. It would be taken out when the debugging was done.

    Are you done with this project now? Not interested in getting it to work now that its been turned in?
  2. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Here are a couple of suggestions to start with:
    0) fix the formatting so the code is readable
    1)Change the variable names from n and m to numKids and numWords to make the code readable
    2)Debug it...
  3. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    No. It looks like a bunch of random code without any meaning.
    Post#4 was much closer, but I can not believe you wrote it.
  4. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    You posted the stack trace in posts#17, 19, 21 and 25

    It starts with:
    Exception in thread ...
    and is followed by several lines that begin with
    at ...
    at ...
  5. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Where is the stack trace?
    That has happened several times in this thread. You should know by now how to fix it.

    BTW Most of your comments only say what the code is obviously doing. They should...
  6. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Does it compile? If it does then the code is legal.
    There are no comments with the code describing what its logic is supposed to be so it's hard to see if the code is doing what the programmer...
  7. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Use one int value in a slot to show the child is present and have another value to show that the child has been removed. For example: 0 means child is present and 1 means the child has been removed....
  8. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Is the code in an infinite loop? To see, add some println() statements inside of the loops. Have them print out the values of the variables that are controlling the looping. The values printed will...
  9. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Did you read posts #18 and 24 about how to code the termination condition in a for loop?

    BTW The code should use the array's .length field to test the end of the array, not the variable:n
  10. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Yes it does. The line number is given in the stack trace:

    The error is on line 20.


    Paste all the lines that define and set values for the code used on line 20.
  11. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Please copy the statement where the error happens and paste it here.

    From post#18 (you should read what has been posted)
  12. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    What statement is giving the error? If its in a for loop:
    Change the code so the index stops before it goes past the end of the array.
    If the array has 10 slots, the indexes range from 0 to 9 (the...
  13. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Look at how to code a for statement. The compiler doesn't like what is coded now.
    See the tutorial: The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)

    A for...
  14. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    The correct technique works with all arrays. What is in the array is not relevant.

    The for loop's termination condition should be when the value of the index matches the array length.
    Keep...
  15. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    The code in post #4 shows a technique for using an array in a circular way. If you wrote that, you know how to do it.


    The code is comparing an int: j with a boolean: kids[n-j]
    That is not...
  16. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    The code at line 17 used an index (10) past the end of the array. Look at the code on line 17 and before that line to see why it had an index value past the end of the array.
    Remember: array...
  17. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Or have a boolean array named: removed with the default false (not removed) and true when removed.
    That saves the useless loop to set the array's value to true. Use the default false values.
  18. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    Please copy the full text of the error message and paste it here. It has important info about the error.

    Where did the code in post#4 come from? Why is the code in post#8 so different?
  19. Replies
    43
    Views
    2,253

    Re: Count out program-- How do i do this?

    import java.util.*;
    public class Countout{
    public static void main (String[]args){
    Scanner in = new Scanner (System.in);

    System.out.printf("Enter # of children [<=100]:");
    int...
Results 1 to 19 of 19