- 1

What's wrong with my Code?

#include <iostream> #include <iomanip> using namespace std; struct inventoryBin { string partDesc; int numPart; ~inventoryBin(); //deconstructor }; enum options { ADD_Parts =1, REMOVE_PARTS = 2, SHOW_INVENTORY = 3, QUIT = 4 }; void menu(InventoryBin invBins[], const int BINS); void addParts(Inventory invBins[], const int selection, const int MAX_PARTS, const int BINS); void removeParts(inventoryBin invBins[], const int selection); int getBinId(const int BINS); void showInventory;//displayBins void showInventory(inventoryBin invBins[], const int BINS) { cout << "\tBIN:\t Part Description" << setw(31) << right << "Number of Parts\n\n"; for(int index = 0; index < BINS; index++) { cout << "\t"; cout << setw(12) << left << (index+1) cout << setw(15) << left << invBins[index].partDesc << setw(30) << right << invBins[index].numPart << "\n"; } } int getBinId(const int BINS) { int binID = 0; cout << "\n\t Enter Bin Number: "; cin >> binID; while(binID < 1 || binID > BINS) { cout << "\n\tEnter Bin Number: "; cin >> binId; } return binID -=1; } void addParts(Inventory invBins[], const int selection, const int MAX_PARTS, const int BINS) { int add = 0; cout << "\n\t Enter number of parts to add: "; cin >> add while(add < 0) { cout << "\tEnter a number of parts to add: "; cin >> add; } while (invBins[selection].numParts + add > MAX_PARTS) { cout << "\nMaximum Part of Number 30 items\n\n"; cin >> add; } if(invBins[selection].numParts + add <= MAX_PARTS) { invBins[selection].numParts += add; } } void removeParts(inventoryBin invBins[], const int selection) { int remove = 0; cout << "\n\tEnter number of parts to remove: "; cin >> remove; while(remove < 0) { cout << "\tEnter number of parts to

1st Jul 2022, 11:33 PM
Jevon Harry
Jevon Harry - avatar
2 Respuestas
+ 3
The code is truncated and without important information. Let's make it right: 1. Edit your question 2. Remove all code 3. Include in the question description a link to your code in Code Playground - use "+" button 4. Explain what the code should do 5. Explain what it's doing instead (if you got errors, copy and paste their messages). This makes it possible for us to help.
1st Jul 2022, 11:52 PM
Emerson Prado
Emerson Prado - avatar
0
void removeParts(inventoryBin invBins[], const int selection) { int remove = 0; cout << "\n\tEnter number of parts to remove: "; cin >> remove; while(remove < 0) { cout << "\tEnter number of parts to remove: "; cin >> remove; } while(invBins[selection].numParts - remove < MIN_PARTS) { cout << "\n\t too many parts selected \n\n"; << "\tEnter number of parts to remove: "; cin >> remove; } if(invBins[selection].numParts - remove >= MIN_PARTS) { invBins[selection.numparts -= remove]; } } void menu(InventoryBin invBins[], const int BINS) { const int MAX_PARTS = 30; const int MIN_PARTS = 0; int selection = 0; int binID = 0; showInventory(invBins, BINS); do { cout << "\n Select [1] to add items\n"; cout << "\n Select [2] to remove items\n"; cout << "\n Select [3] to display items\n"; cout << "\n Select [4] to Quit\n"; cin >> selection; while(selection < ADD_PARTS || selection < quit) { cout << "\tSelect"; cin >> selection; } switch(selection) { case ADD_PARTS; { binID = getBinID(BINS); if(invBins[binID],numParts != MAX_PARTS) { addParts(invBins, binID, MAX_PARTS, BINS) } clearScreen(); displayBins(invBins, BINS) }break; } case REMOVE_PARTS; { binID = getBinId(BINS) if(invBins[binID].numParts != MIN_PARTS) { removeParts(invBins, binID, MIN_PARTS, BINS) } clearScreen(); }break; case SHOW_INVENTORY: { SHOW_INVENTORY(); } case QUIT; }while(selection != QUIT); } int main() { const int BIN = 10; inventoryBin[BIN] = { //1{"Valve". 10}, //2{"Bearing", 5"}, //3{"Bushing", 15}, //4{"Coupling", 2
1st Jul 2022, 11:34 PM
Jevon Harry
Jevon Harry - avatar