School project (c++ Inventory management program)












0














I recently started working on a project. The task is the following:
Write a program to keep a list of available items in a sports goods store. For each item, the following information must be stored: Name, Manufacturer, Price, Available items. The program should support the following features, as a text menu from which the user can choose:



• Enter a new item in the list
• Search by Manufacturer of an item
• Sort items in the list by Name
• Display the current content of the list



I was advised this on another topic:



1) For the menu, you would make a function that displays the information and returns the input after verifying that it's a valid input. You can use pass by reference. Don't bother about functions if you haven't learn it yet. Then just use switch case like you said.



2) For adding an item, (again make a function if you have learnt about it) make a temporary ITEMS object and ask the user for the various required inputs like price and then directly read the inputs into the object (eg. cin >> object.price). After getting all information, simply push the object into the vector we had.



3) For searching by Manufacturer's name you simple need to compare the given name with the manufacturer's name from each element of the vector.



4) Sort the elements of the vector based on their name parameter.



5) Simply print out all parameters of each element in the vector.



I will create a vector after learning more about them, and I will enter below the code which I have written so far. My questions here is should i follow the five tips on top or not. If you think I should not, please share your insights with different suggestions. I know this topic will probably be closed because I did read all the rules but still some information could be crucial. Thanks in advance and I'm sorry if this essay of mine has been time-consuming.



    #include <iostream>
#include <conio.h>
#include <string.h>
#include <dos.h>
#include <vector>

using namespace std;

struct articles
{
char name[20];
char manufacturer[15];
double price;
char available;
};

int main()
{
int choice;

do
{
cout << ("n ##################################################");
cout << ("n # Menu #");
cout << ("n # 1.Enter new article #");
cout << ("n # 2.List of manufacturers of articles #");
cout << ("n # 3.Sort articles by name #");
cout << ("n # 4.Display the current content of the list #");
cout << ("n # 5. End of program #");
cout <

< ("n ##################################################") << endl;
cin >> choice;

switch (choice)
{

case 1:
articles newart;
cout << ("Enter a name: ");
cin >> (newart.name);
cout << ("Enter a manufacturer: ");
cin >> (newart.manufacturer);
cout << ("Enter a price: ");
cin >> (newart.price);
cout << ("Enter if its available (y/n): ");
cin >> (newart.available);
cout << ("The new article you've created is the following: n");
cout << newart.name << endl;
cout << newart.manufacturer << endl;
cout << newart.price << endl;
cout << newart.available << endl;
break;

/* case 2:
//code
break;
case 3:
//code
break;
case 4:
//code
//extra information about the mode and the controller
break;
case 5:
cout << "End of Program.n";
break;
*/

default:
cout << "Not a Valid Choice. n"
<< "Choose again.n";
break;
}




}while (choice != 5);
return 0;
}









share|improve this question


















  • 1




    Yes, those seem like good suggestions (except that I see no reason to pass anything by reference in #1). I will add one more: start with something simple, then add complexity slowly. Write code that sorts a container of int before you attempt to sort a container of articles (and don't give a plural name to a struct that represents one thing).
    – Beta
    Nov 22 at 21:45
















0














I recently started working on a project. The task is the following:
Write a program to keep a list of available items in a sports goods store. For each item, the following information must be stored: Name, Manufacturer, Price, Available items. The program should support the following features, as a text menu from which the user can choose:



• Enter a new item in the list
• Search by Manufacturer of an item
• Sort items in the list by Name
• Display the current content of the list



I was advised this on another topic:



1) For the menu, you would make a function that displays the information and returns the input after verifying that it's a valid input. You can use pass by reference. Don't bother about functions if you haven't learn it yet. Then just use switch case like you said.



2) For adding an item, (again make a function if you have learnt about it) make a temporary ITEMS object and ask the user for the various required inputs like price and then directly read the inputs into the object (eg. cin >> object.price). After getting all information, simply push the object into the vector we had.



3) For searching by Manufacturer's name you simple need to compare the given name with the manufacturer's name from each element of the vector.



4) Sort the elements of the vector based on their name parameter.



5) Simply print out all parameters of each element in the vector.



I will create a vector after learning more about them, and I will enter below the code which I have written so far. My questions here is should i follow the five tips on top or not. If you think I should not, please share your insights with different suggestions. I know this topic will probably be closed because I did read all the rules but still some information could be crucial. Thanks in advance and I'm sorry if this essay of mine has been time-consuming.



    #include <iostream>
#include <conio.h>
#include <string.h>
#include <dos.h>
#include <vector>

using namespace std;

struct articles
{
char name[20];
char manufacturer[15];
double price;
char available;
};

int main()
{
int choice;

do
{
cout << ("n ##################################################");
cout << ("n # Menu #");
cout << ("n # 1.Enter new article #");
cout << ("n # 2.List of manufacturers of articles #");
cout << ("n # 3.Sort articles by name #");
cout << ("n # 4.Display the current content of the list #");
cout << ("n # 5. End of program #");
cout <

< ("n ##################################################") << endl;
cin >> choice;

switch (choice)
{

case 1:
articles newart;
cout << ("Enter a name: ");
cin >> (newart.name);
cout << ("Enter a manufacturer: ");
cin >> (newart.manufacturer);
cout << ("Enter a price: ");
cin >> (newart.price);
cout << ("Enter if its available (y/n): ");
cin >> (newart.available);
cout << ("The new article you've created is the following: n");
cout << newart.name << endl;
cout << newart.manufacturer << endl;
cout << newart.price << endl;
cout << newart.available << endl;
break;

/* case 2:
//code
break;
case 3:
//code
break;
case 4:
//code
//extra information about the mode and the controller
break;
case 5:
cout << "End of Program.n";
break;
*/

default:
cout << "Not a Valid Choice. n"
<< "Choose again.n";
break;
}




}while (choice != 5);
return 0;
}









share|improve this question


















  • 1




    Yes, those seem like good suggestions (except that I see no reason to pass anything by reference in #1). I will add one more: start with something simple, then add complexity slowly. Write code that sorts a container of int before you attempt to sort a container of articles (and don't give a plural name to a struct that represents one thing).
    – Beta
    Nov 22 at 21:45














0












0








0







I recently started working on a project. The task is the following:
Write a program to keep a list of available items in a sports goods store. For each item, the following information must be stored: Name, Manufacturer, Price, Available items. The program should support the following features, as a text menu from which the user can choose:



• Enter a new item in the list
• Search by Manufacturer of an item
• Sort items in the list by Name
• Display the current content of the list



I was advised this on another topic:



1) For the menu, you would make a function that displays the information and returns the input after verifying that it's a valid input. You can use pass by reference. Don't bother about functions if you haven't learn it yet. Then just use switch case like you said.



2) For adding an item, (again make a function if you have learnt about it) make a temporary ITEMS object and ask the user for the various required inputs like price and then directly read the inputs into the object (eg. cin >> object.price). After getting all information, simply push the object into the vector we had.



3) For searching by Manufacturer's name you simple need to compare the given name with the manufacturer's name from each element of the vector.



4) Sort the elements of the vector based on their name parameter.



5) Simply print out all parameters of each element in the vector.



I will create a vector after learning more about them, and I will enter below the code which I have written so far. My questions here is should i follow the five tips on top or not. If you think I should not, please share your insights with different suggestions. I know this topic will probably be closed because I did read all the rules but still some information could be crucial. Thanks in advance and I'm sorry if this essay of mine has been time-consuming.



    #include <iostream>
#include <conio.h>
#include <string.h>
#include <dos.h>
#include <vector>

using namespace std;

struct articles
{
char name[20];
char manufacturer[15];
double price;
char available;
};

int main()
{
int choice;

do
{
cout << ("n ##################################################");
cout << ("n # Menu #");
cout << ("n # 1.Enter new article #");
cout << ("n # 2.List of manufacturers of articles #");
cout << ("n # 3.Sort articles by name #");
cout << ("n # 4.Display the current content of the list #");
cout << ("n # 5. End of program #");
cout <

< ("n ##################################################") << endl;
cin >> choice;

switch (choice)
{

case 1:
articles newart;
cout << ("Enter a name: ");
cin >> (newart.name);
cout << ("Enter a manufacturer: ");
cin >> (newart.manufacturer);
cout << ("Enter a price: ");
cin >> (newart.price);
cout << ("Enter if its available (y/n): ");
cin >> (newart.available);
cout << ("The new article you've created is the following: n");
cout << newart.name << endl;
cout << newart.manufacturer << endl;
cout << newart.price << endl;
cout << newart.available << endl;
break;

/* case 2:
//code
break;
case 3:
//code
break;
case 4:
//code
//extra information about the mode and the controller
break;
case 5:
cout << "End of Program.n";
break;
*/

default:
cout << "Not a Valid Choice. n"
<< "Choose again.n";
break;
}




}while (choice != 5);
return 0;
}









share|improve this question













I recently started working on a project. The task is the following:
Write a program to keep a list of available items in a sports goods store. For each item, the following information must be stored: Name, Manufacturer, Price, Available items. The program should support the following features, as a text menu from which the user can choose:



• Enter a new item in the list
• Search by Manufacturer of an item
• Sort items in the list by Name
• Display the current content of the list



I was advised this on another topic:



1) For the menu, you would make a function that displays the information and returns the input after verifying that it's a valid input. You can use pass by reference. Don't bother about functions if you haven't learn it yet. Then just use switch case like you said.



2) For adding an item, (again make a function if you have learnt about it) make a temporary ITEMS object and ask the user for the various required inputs like price and then directly read the inputs into the object (eg. cin >> object.price). After getting all information, simply push the object into the vector we had.



3) For searching by Manufacturer's name you simple need to compare the given name with the manufacturer's name from each element of the vector.



4) Sort the elements of the vector based on their name parameter.



5) Simply print out all parameters of each element in the vector.



I will create a vector after learning more about them, and I will enter below the code which I have written so far. My questions here is should i follow the five tips on top or not. If you think I should not, please share your insights with different suggestions. I know this topic will probably be closed because I did read all the rules but still some information could be crucial. Thanks in advance and I'm sorry if this essay of mine has been time-consuming.



    #include <iostream>
#include <conio.h>
#include <string.h>
#include <dos.h>
#include <vector>

using namespace std;

struct articles
{
char name[20];
char manufacturer[15];
double price;
char available;
};

int main()
{
int choice;

do
{
cout << ("n ##################################################");
cout << ("n # Menu #");
cout << ("n # 1.Enter new article #");
cout << ("n # 2.List of manufacturers of articles #");
cout << ("n # 3.Sort articles by name #");
cout << ("n # 4.Display the current content of the list #");
cout << ("n # 5. End of program #");
cout <

< ("n ##################################################") << endl;
cin >> choice;

switch (choice)
{

case 1:
articles newart;
cout << ("Enter a name: ");
cin >> (newart.name);
cout << ("Enter a manufacturer: ");
cin >> (newart.manufacturer);
cout << ("Enter a price: ");
cin >> (newart.price);
cout << ("Enter if its available (y/n): ");
cin >> (newart.available);
cout << ("The new article you've created is the following: n");
cout << newart.name << endl;
cout << newart.manufacturer << endl;
cout << newart.price << endl;
cout << newart.available << endl;
break;

/* case 2:
//code
break;
case 3:
//code
break;
case 4:
//code
//extra information about the mode and the controller
break;
case 5:
cout << "End of Program.n";
break;
*/

default:
cout << "Not a Valid Choice. n"
<< "Choose again.n";
break;
}




}while (choice != 5);
return 0;
}






c++ vector menu structure






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 20:03









plamen bozhanov

1




1








  • 1




    Yes, those seem like good suggestions (except that I see no reason to pass anything by reference in #1). I will add one more: start with something simple, then add complexity slowly. Write code that sorts a container of int before you attempt to sort a container of articles (and don't give a plural name to a struct that represents one thing).
    – Beta
    Nov 22 at 21:45














  • 1




    Yes, those seem like good suggestions (except that I see no reason to pass anything by reference in #1). I will add one more: start with something simple, then add complexity slowly. Write code that sorts a container of int before you attempt to sort a container of articles (and don't give a plural name to a struct that represents one thing).
    – Beta
    Nov 22 at 21:45








1




1




Yes, those seem like good suggestions (except that I see no reason to pass anything by reference in #1). I will add one more: start with something simple, then add complexity slowly. Write code that sorts a container of int before you attempt to sort a container of articles (and don't give a plural name to a struct that represents one thing).
– Beta
Nov 22 at 21:45




Yes, those seem like good suggestions (except that I see no reason to pass anything by reference in #1). I will add one more: start with something simple, then add complexity slowly. Write code that sorts a container of int before you attempt to sort a container of articles (and don't give a plural name to a struct that represents one thing).
– Beta
Nov 22 at 21:45

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437438%2fschool-project-c-inventory-management-program%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437438%2fschool-project-c-inventory-management-program%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

A CLEAN and SIMPLE way to add appendices to Table of Contents and bookmarks

Calculate evaluation metrics using cross_val_predict sklearn

Insert data from modal to MySQL (multiple modal on website)