Search:

Type: Posts; User: Norm

Search: Search took 0.12 seconds.

  1. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    Move the code that gets the price of the entered item (post#16) INSIDE the loop so it follows the code that gets the item number from the users.
  2. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    Where do you add the price of the item to the total?
    If you want the add more prices to the total, you need to have code to do that after the item number is entered.
  3. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    What does the code inside the while loop do?
    Where do you add the price of the item to the total?
    If you want the add more prices to the total, you need to have code to do that after the item...
  4. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    Can you post the full code that shows where the above bit of code is executed?
  5. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    @javaiscool Please do not do OPs work for him.
    See: http://www.javaprogrammingforums.com/cafe/9544-problem-spoon-feeding.html
  6. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    See the tutorial:
    Arrays (The Java™ Tutorials > Learning the Java Language > Language Basics)

    or ask google

    or Search here on the forum
  7. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    Do you know how to use arrays?
    Make an array with the prices such that using the product number as the index gets the price.
  8. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    That depends on what the code does with the data:
    To count the number of items:
    counter++; // add one to count of items

    or to total their values:
    total = total + thisItem; // add the value of...
  9. Replies
    24
    Views
    1,518

    Re: Working with loops for the first time.

    That depends on what you want the loop to do and how many times you want to loop.

    The for loop is used mainly when you know how many times you want to loop. Like when going through the contents of...
Results 1 to 9 of 9