I am rather new to programming and am coming across a problem with my current program. The program shows bins full of parts. It shows the name of the bin and then how many parts are in the bin. The program then asks for the user to update the data in the bins. The problem I cannot figure out is how to update the data in the array of bins. For instance, the program runs, I choose to add 5 parts to the Valve bin, how do I make th valve bin show this change when the program loops back again? I have made a couple attempts only to find that I have no idea right now. I'll appreciate any guidance and help you can give. Thanks! - ..const int LENGTH = 20;
-
-
struct Data
-
{
-
char description[LENGTH];
-
int number;
-
-
};
-
-
int main()
-
{
-
Data part;
-
int choice;
-
int b;
-
int add=0;
-
int remove=0;
-
Data bins[10] = {
-
{"Valve",10},
-
{"Bearing",5},
-
{"Bushing",15},
-
{"Coupling",21},
-
{"Flange",7},
-
{"Gear",5},
-
{"Gear Housing",5},
-
{"Vacuum Gripper",25},
-
{"Cable",18},
-
{"Rod",12}
-
};
-
for( ; ; )
-
{
-
cout<<endl;
-
for (int index = 0; index < 10; index++)
-
{
-
cout<< right << setw(8)<< "Part Description: " << bins[index].description;
-
cout<< right << setw(8)<< " Number of parts in bin: " << bins[index].number <<endl;
-
-
}
-
cout << "\n\t\tPROGRAM MENU\n\n";
-
cout << "0. Valve\n";
-
cout << "1. Bearing\n";
-
cout << "2. Bushing\n";
-
cout << "3. Coupling\n";
-
cout << "4. Flange\n";
-
cout << "5. Gear\n";
-
cout << "6. Gear Housing\n";
-
cout << "7. Vacuum Gripper\n";
-
cout << "8. Cable\n";
-
cout << "9. Rod\n";
-
cout <<endl;
-
cout << "Enter choice from the Menu to select a bin: ";
-
cin >> choice;
-
-
cout << "\nYou have selected the " << bins[choice].description << " bin with " << bins[choice].number << " parts in it." <<endl;
-
cout << "\nWould you like to add parts or remove parts? \nEnter number choice from menu please.\n";
-
cout << "\n\t\tADD/REMOVE MENU\n\n";
-
cout << "1. ADD PARTS TO A BIN\n";
-
cout << "2. REMOVE PARTS FROM A BIN\n";
-
cout <<endl;
-
cin >> b;
-
if (b == 1)
-
{
-
cout << "\nType the number of parts you would like to add to the bin: ";
-
cin >> add;
-
while ( add + bins[choice].number > 30)
-
{
-
cout << "\nThe number is too great. The bin can hold no more than 30 parts.";
-
cout << "\nPlease try a different number: ";
-
cin >> add;
-
-
}
-
-
}
-
-
else if(b == 2)
-
{
-
-
-
cout << "\nType the number of parts you would like to remove from the bin: ";
-
cin >> remove;
-
while (remove < 0)
-
{
-
cout << "\nPlease enter a positive number only: ";
-
cin >> remove;
-
}
-
-
}
-
}
-
getch();
-
}..
1 2303
Aside of your lack of headers, your for loop that should be a while and has no exit, I don't see, logically, where you try to add something to the bins - you just check to see if it's over 30 when added to another element. Am I just missing that, or can you post that specific part of the code you're having trouble with?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: David |
last post by:
I have an array that contains numbers in string elements , i want to convert
this to integers, i have made a for loop that uses the number of elements in
the array and then adds 0, thereby...
|
by: R.G. Vervoort |
last post by:
Not sure if it is a php question but since i am working in php here it is.
Ho can i add items to (the item label=visual text and the value=index
number) a list object on a website.
I am having...
|
by: MCD |
last post by:
Hello, I'm new to python and this group and am trying to build some
bins and was wondering if any of you could kindly help me out. I'm a
bit lost on how to begin.
I have some text files that...
|
by: Stephen |
last post by:
I have been getting on well with help from this forum trying to create an
array list and work with it. Everything is working fine apart from
displaying my array list items into the labels in my...
|
by: Jim Heavey |
last post by:
Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that...
|
by: Karl Irvin |
last post by:
While adding data to a record set, I use something like
rst! = some variable
rst! = some variable
......
rst! = some variable
The rst! , rst! etc. are manually typed in and it gets...
|
by: Paul_Madden via DotNetMonster.com |
last post by:
Basically I have a listbox to which I add simple STRING items- I have a
progress bar which I increment whenever I populate another portion of the
complete set of items I wish to add. What I observe...
|
by: Phat G5 (G3) |
last post by:
I was toying around with adding a new method to the Array class. It works
fine in FF but not in Safari. I have no idea in IE. I have not gotten that
far yet.
Array.prototype.find =...
|
by: Kiamari |
last post by:
here's what i have to do:
Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |