Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6992727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:40:20+00:00 2026-05-27T19:40:20+00:00

This is about my assignment so I would appreciate generic answers with explanation. I

  • 0

This is about my assignment so I would appreciate generic answers with explanation.

I have a for-loop which I have to make for an online ordering system. The for-loop and ordering all works fine but if the same item is put in twice, then it forgets the previous order for the same item and only remembers the latest one. I am required to use simple arrays and for-loops so I would appreciate if the solution/help was also of this basic level.

My code looks something like this (NOTE: The following is just an example of what part of the loop looks like–this is not a complete program):

for (int i = 0; i < 3; i++) { //I changed the loop so there's no confusion about
                              //what I am actually asking about.
    if (order.equalsIgnoreCase(computer) {
         int price = quantity[i] + itemcode;
    }
}

To explain further, this loop and the if statement work perfectly if a certain item is only ordered once. But if the user enters, say, an order for a computer once and then after 3 more orders, orders another computer, then the output does not add the previous order in the new order but only remembers the latest one.

I would appreciate any work around suggested for this but again, since this is for my studies, I would appreciate explanations rather than direct solutions.

Please ask me questions in case this is not clear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:40:20+00:00Added an answer on May 27, 2026 at 7:40 pm

    “Forgets” suggests that you are overwriting something in your code rather than, say, just incrementing. Go through your code, see what parts of it gets reset when you place a new order. For instance, if you are doing

    quantity[1] = getNumberFromUser("How many apples?");

    then this would obviously erase the old value each time. If you want to merely increment the number of apples, do something like

    quantity[1] += getNumberFromUser("How many apples?");

    Another general advice is to use print statements to debug your code. That way you can see for yourself what really happens. Learning to use a real debugger would also be of great benefit.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a assignment about this. For Eaxmple: I have a message (String),
This is about a school assignment so I'm trying to do things by the
This question about Timers for windows services got me thinking: Say I have (and
This is about asp.net mvc3 web application. We have used Object cache to store
I have an assignment problem at hand and am wondering how suitable it would
I asked this question about overloading the copy constructor and assignment operator with template
I have a piece of code from an assignment I am uncertain about. I
For a database assignment I have to model a system for a school. Part
This is one of the tasks of my assignment. I have a Turing machine
I am pulling me hair out about this one. http://www.nettunes.co.za/build/contact.php I have an image

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.