Search:

Type: Posts; User: Elyril

Search: Search took 0.16 seconds.

  1. Replies
    11
    Views
    1,423

    [SOLVED] Re: Average and counting problem (sorta)

    Thanks. I did this instead:
    sum += numbers and
    avg = ((double) sum / total)
  2. Replies
    11
    Views
    1,423

    [SOLVED] Re: Average and counting problem (sorta)

    I changed my loop and compute to this

    //do-while loop w/ sum inside
    do {
    System.out.print("Enter any positive or negative number (0 ends program): ");
    numbers = input.nextInt();
    ...
  3. Replies
    11
    Views
    1,423

    [SOLVED] Re: Average and counting problem (sorta)

    Enter any positive or negative number (0 ends program): -5
    Enter any positive or negative number (0 ends program): 2
    Enter any positive or negative number (0 ends program): -10
    Enter any positive...
  4. Replies
    11
    Views
    1,423

    [SOLVED] Re: Average and counting problem (sorta)

    Thanks for that. I just added
    else if (numbers == 0) {total--;} into the nested if's and it counted right, but now, I found out my averages, even if I go put a negative into the equation, the...
  5. Replies
    11
    Views
    1,423

    [SOLVED] Re: Average and counting problem (sorta)

    What do you mean to add code to test for the 0 with an if statement?
  6. Replies
    11
    Views
    1,423

    [SOLVED] Average and counting problem (sorta)

    So, my code compiles fine and everything with a do-while loop, but when it counts how many numbers there are and averages them all, the count adds the 0 and the average also includes the 0 which I...
Results 1 to 6 of 6