I'm trying to make a simple food database using a maximum of 50 foods stored.
The options are: a) add a food, d) delete a food, l) list all foods, m) "meal mode" and q) to quit.
Q to quit is simple, it's the other things involving arrays are the trouble...
A is a series of cout/cin statements including:
char name[SIZE]; // name of the food
Category category; // what kind of food***
float calories; // calories
float carbohydrates; // grams
float fat; // grams
float cholesterol; // grams
float sodium; // grams
float protein; // grams
***Category was defined by:
enum Category {
unknown = -1, meat, poultry, seafood, dairy, vegetable,
fruit, grain, sweet, nCategory
};
M, D and L list what has been added, D gives the additional option of removing an item and M lists by food name (assigned a number starting at 0) and displays the remaining info of the food that's picked. I don't know how to implement any of this stuff as it all involves arrays, any advice?
This is my code so far:
#include <iostream>
using namespace std;
int main(void)
{
char choice;
bool terminate = false
char name[SIZE]; // name of the food
Category category; // what kind of food
enum Category {
unknown = -1, meat, poultry, seafood, dairy, vegetable,
fruit, grain, sweet, nCategory };
while(!terminate)
{
cout << "Enter an option for the database:\n"
<< "(a) to add a food\n"
<< "(d) to delete a food\n"
<< "(l) to list all food items\n"
<< "(m) to enter Meal Mode\n"
<< "(q) to quit\n";
So that will assign it's number, I'm also wondering how to store all that data from choice A in one array value like I just did for the food name. How do I associate the name with it corresponding calories, fat, etc?
NEW:
#include <iostream>
using namespace std;
const int SIZE = 50;
int main(void)
{
char choice;
bool terminate = false
char name[SIZE]; // name of the food
enum Category {
unknown = -1, meat, poultry, seafood, dairy, vegetable,
fruit, grain, sweet, nCategory };
Category category; // what kind of food
float calories; // calories
float carbohydrates; // grams
float fat; // grams
float cholesterol; // grams
float sodium; // grams
float protein; // grams
while(!terminate)
{
cout << "Enter an option for the database:\n"
<< "(a) to add a food\n"
<< "(d) to delete a food\n"
<< "(l) to list all food items\n"
<< "(m) to enter Meal Mode\n"
<< "(q) to quit\n";