Create a program that is a Point of Sales (POS) system for a restaurant. Your POS system should allow unlimited orders from any number of guest. Each guest should be able to order a drink, an appetizer, an entree, and a dessert. The program should present a total. In addition, the program should allow user to add to the order, delete from the order, and separate orders. Creativity is advised.

This is the current project that I have been assigned and I have no clue where to even start it. We have briefly covered arrays and I am not sure how to even go about writing code for this project. I am not asking anyone to code it for me, but if you could please help me look at some things that would allow me to understand how to write the code for this I would greatly appreciate it.

The purpose of school work is to learn how to think. To analyze problems, and come up with appropriate solutions. Break the problem up into parts. Identify classes of objects in the system, what their properties should be, and what their behaviors should be. Solve the problem intellectually and symbolically, then you will be ready to start writing software to implement the solution.

commented: good suggestions +17
commented: Here's some of the "new rep" :) +14

I'm unsure what you mean by that. The furthest we have covered was using arrays and I don't know how to fill the array with numbers that the user inputs based on how many guests there are.

When is your assignment due? You will need to know about input/output functions like cin and cout, as well as arrays and optionally structures. You will need some way to hold the name of the item ordered and quantity of each item. You can do that with either two arrays (one for name and the other for quantity), a structure, or c++ class.

Your program will also have to have some way to calculate total price of each guest's bill. To do that you will have to have another array of menu item names and their prices. You can do that with a structure that contains item name and price, or two arrays, one for names and the other for prices. Which one you choose will depend on if you know how to use structures or not. Structures are preferable because they let you keep related items (name and prices) together easier.

The assignment is due Tuesday and I have been struggling with it since last Tuesday. I am familiar with cin and cout, but the only knowledge I have with arrays is how to fill them with random numbers or how to pre set it with numbers. I don't know how I would hold the value of the item ordered either.

you need to know arrays of strings as well as arrays of integers.

Here are a few examples of character arrays. You could also use std::string c++ class, but its doubtful you have learned anything about them yet. You will have to include string.h (or <cstring> ) in order to use strcpy() function shown below.

char name[25]; // an array of characters that hold a name of up to 24 characters

strcpy(name,"Hamburger"); 

char names[5][25]; // an array of 5 names, each namne can have up to 24 characters
strcpy(names[0],"Hamburger");
strcpy(names[1],"Pepsi");
strcpy(names[2],"Fries");
strcpy(names[3],"Milkshake");

so if i rearrange the arrays of 5 names to be my different categories like drink, meal, appetizer and dessert I could store up to 24 different seats at each category? How then would I allow the user to input different values at each array. In theory, I believe the program should work as if the waiter were to take the orders for a certain amount of seats. Each seat would be a different drink so one would be a water at $0, and a few others could be a value at 1.29. I don't understand how I would allow the user to input that. I realize it would be cin<< but I don't know which seat I would do it for and how I would be able to ask the question the appropriate amount of times to correspond with the number of seats.

lets say you have two arrays

char names[5][25];
int quantity[5];

now you, the waiter at the restaurant, ask the guest wbat he wants to order

int itemNumber = 0;
cout << "What do you want to order?";
cin >> names[itemNumber];
cout << "How many?";
cin >> quantity[itemNumber];

Now put all the above in a loop and you have it.

Here's what I have so far. Obviously it loops through and just keeps looping so when I want to store values let's say seat one ordered a water for 0.00, seat two ordered a soda for 1.29 and seat 3 did as well. Then would I have to go through a separate loop for each of the other items such as meal, appetizer and dessert? I'm assuming I can use an If statement to allow the user to exit this loop and continue on to other portions of the program.

#include <iostream>
#include <cmath>
#include <string.h>
using namespace std;

int main () 
{
	int i, itemNumber = 0;

char names[5][25]; // an array of 5 names, each name can have up to 24 characters
int quantity[5];
strcpy(names[0],"Drink");
strcpy(names[1],"Appetizer");
strcpy(names[2],"Meal");
strcpy(names[3],"Dessert");

for(int i=0;i<25;i++)
{
int itemNumber = 0;
cout << "What do you want to order?";
cin >> names[itemNumber];
cout << "How many?";
cin >> quantity[itemNumber];
}




return 0;
}

Your problem would be easy to solve with structs/classes, but it is doable even without them. Let's say each waiter could have up to 25 orders at any one time. Each order could have a customer identifier (seat number, customer name, whatever) and each customer could purchase one or more of any of the following water/coffee/soda, hamburger/fries/hot dog/salad. You could create a series of arrays with 25 elements. Each array would control one piece of information. One array could hold 25 customer IDs. You could then have 7 other arrays of 25 ints each, one called water, one called coffee, one called soda, one called hamburger, one called fries, etc. The index of each element in each array would be the key to determining which customer ordered how many sodas and how many hamburgers and how many fries, etc. You would then have another array to hold the price for each menu item and another array to hold the total cost for each customer. Each array would be initialized to zero or some other equally banal default value and every time a bill was paid and the customer left you would reassign the default value to the appropriate index in each array.

If you wanted, you could let the element index value be the customer ID, but it's kind of nice to call a customer by their name or an order number or something rather than calling them customer zero or customer 21, etc.

I think I understand what you mean partially because I believe I have almost set my problem up like that. Instead of my current arrays such as drink, meal and so on, you are recommending that I create separate item arrays in there place? If that's the case then I can easily correct that but I'm not sure what you mean when you said "The index of each element in each array would be the key to determining which customer ordered how many sodas and how many hamburgers and how many fries, etc. You would then have another array to hold the price for each menu item and another array to hold the total cost for each customer. Each array would be initialized to zero or some other equally banal default value and every time a bill was paid and the customer left you would reassign the default value to the appropriate index in each array." Unfortunately I'm still at best a super beginner when it comes to programming and I am teaching myself arrays as we speak so if you could just show me what you mean in code I'd appreciate it, if not I completely understand that what I'm asking for is both time consuming and tedious.

Here's what I have so far. Obviously it loops through and just keeps looping so when I want to store values let's say seat one ordered a water for 0.00, seat two ordered a soda for 1.29 and seat 3 did as well. Then would I have to go through a separate loop for each of the other items such as meal, appetizer and dessert? I'm assuming I can use an If statement to allow the user to exit this loop and continue on to other portions of the program.

#include <iostream>
#include <cmath>
#include <string.h>
using namespace std;

int main () 
{
	int i, itemNumber = 0;

char names[5][25]; // an array of 5 names, each name can have up to 24 characters
int quantity[5];
strcpy(names[0],"Drink");
strcpy(names[1],"Appetizer");
strcpy(names[2],"Meal");
strcpy(names[3],"Dessert");

for(int i=0;i<25;i++)
{
int itemNumber = 0;
cout << "What do you want to order?";
cin >> names[itemNumber];
cout << "How many?";
cin >> quantity[itemNumber];
}




return 0;
}

1. itemNumber has to be declared outside the for loop so that it doesn't get reinitialized on each loop iteration.

2. The arrays you posted only has room for 5 items, so the loop needs to count from 0 to 5, not 25.

Those arrays will hold items for just one person. If you need to store items for more than one person, all at the same time, then you will need a 3 dimensional arrays

int maxPeople = 5;
int maxItems = 5;
int maxNameLength = 25;
char names[maxPeople][maxItems][maxNameLength]; // an array of 5 names, each name can have up to 24 characters
int quantity[maxPeople][5];

float prices[maxPeople][maxItems] = {0.0F};

I have re-written the code but it still is just looping through the process. I'm still unsure of how I can declare which item the customer wants as well.

#include <iostream>
#include <cmath>
#include <string.h>
using namespace std;

int main () 
{
int i, itemNumber = 0;
int maxPeople = 5;
int maxItems = 5;
int maxNameLength = 25;
char names[maxPeople][maxItems][maxNameLength]; // an array of 5 names, each name can have up to 24 characters
int quantity[maxPeople][5];
 
float prices[maxPeople][maxItems] = {0.0F};



for(int i=0;i<5;i++)
{

cout << "What do you want to order?";
cin >> names[itemNumber];
cout << "How many?";
cin >> quantity[itemNumber];
}




return 0;
}

I agree, multidimensional arrays would work, but given where the OP is in the learning curve, I suspect that that concept is a step or two down the road.

const int MAX = 25;

int water[MAX];
int fries[MAX];

The customer associated with element whose index is 2 (whose ID is 2) ordered water[2] number of of waters and fries[2] number of fries (and hamburgers[2] number of hamburgers and soda[2] number of sodas, etc). So you could use the element index number as the customer ID, if you wanted.

Now lets say you have an array of doubles called prices and an array of strings called menuItems. Then you could calculate a tab for customer number 2 by using a loop that creates a running total storing the total price in another array:

for each customer
  tab starts a zero
  for each menu item in the prices array
    increase tab by this price times # of this item purchased by this customer
  assign tab to total price array

and, with a little further refinement, you could display the invoice for any given customer by displaying something like:

Sam ordered:
   0.00  1 water at no cost
  11.98  2 hamburgers at 5.99 each  
   3.99  1 fry at 3.99 each
  15.97  Total

EDIT: I tend to write responses at work during down time so my responses aren't always the most on time. If I'm confusing you by sticking with just single dimensional arrays, then go your merry way, learning as you go.

I'm not positive I understand how I would go about using the array and with the index. I'm not seeing how one person could be in a part of the array and order different things.

I'm still extremely lost. I've been struggling for the past couple of days and because of the storms here in St. Louis power has been back and forth. Here's what I've come up with so far and it won't even compile. I would like to be able to use the menu array in conjunction with the price array but I don't know how to access the user to select either and for the value to store.

#include <iostream>
#include <cmath>
#include <string.h>
using namespace std;

int main () 
{
int i, n, quantity, option;
bool finished = false;
char water, soda, nachoes, wings, salad, hamburger, chicken, pasta, cake, icecream;
char menu[10] = {water, soda, nachoes, wings, salad, hamburger, chicken, pasta, cake, icecream};
int price[10] = {0.00, 1.29, 4.99, 5.99, 5.99, 8.99, 10.99, 12.99, 6.99, 5.99};
char seats[n];


cout<< "How many seats are there?";
cin>> n;
 




for(int i=0;i<n;i++)
{

cout << "What do you want to order?";
cin >> menu[]+price[]
cout << "How many?";
cin >> quantity*price[];
cout<< "Are there any other drinks? \n";
cout<< "\n";
cout<< "[1] Yes \n"
	<< "[2] No \n";
cin>>option;

if 
{option == 2 finished= true
}


}




return 0;
}

Okay so here's what I have so far... For me its good enough but I know I can make it better. Is there a way that I can allow the program to keep running and add multiple seats together. The way I have it setup now is for a person to order as many times as they'd like for any quantity and while that may work and be sufficient enough, I would just like to know if there was a way for me to go back in and write it to display Seat 1's ticket, seat 2's ticket and then individual totals then add those subtotals together for a grand total.

#include<iostream>
#include<string>
#include<iomanip>
#include<cstdlib>// allows use of system pause
using namespace std;
struct menuItemType
{string menuItem;
 double menuPrice;  
};
void getdata( menuItemType[],menuItemType[],int&);// array for user to enter data
void showMenu( menuItemType[],int);// array displaying options
void printCheck(menuItemType[],int ); //array stores data
int main()
{
int items=0;
    menuItemType menuList[]={
						  "Water",0.00,
                          "Soda",1.29,
						  "Salad",6.99,
                          "Nachoes",5.99,
                          "Wings",6.99,
                          "Burger",9.99,
						  "Steak",14.99,
                          "Pasta",11.99,
                          "Cake",4.99,
                          "Ice Cream",4.99
                          };
menuItemType order[10];
cout<<"Welcome to the Baltazar Kitchen!\nMenu:\n    Item:\t    Price:\n";
showMenu(menuList,10);// displays menu directly underneath item
getdata(menuList,order,items);// user inputs data
printCheck(order,items);//stores and asks for other items
system("pause");
return 0;
}
void printCheck(menuItemType order[],int items)
{int i;
double total=0,tax;
 cout<<"Your Check\nOrdered Items\n     Item\t     price\n";
 showMenu(order,items);
 for(i=0;i<items;i++)
     total+=order[i].menuPrice;
 cout<<"\nItem total    \t"<<"$"<<setprecision(2)<<fixed<<total<<endl;
 tax=total*.07;//standard tax for st. louis area
 cout<<"Tax\t\t"<<"$"<<setprecision(2)<<fixed<<tax<<endl;
 cout<<"Amount Due    \t"<<"$"<<setprecision(2)<<fixed<<total+tax<<endl;
}
void getdata(menuItemType menu[],menuItemType order[],int& items)
{char yesno='Y';
int n;
while(toupper(yesno)=='Y')
{cout<<"Enter your order item number: ";
cin>>n;
while(n<1||n>10)
    {cout<<"invalid item number\n";
     cout<<"Enter your order item number: ";
     cin>>n;
     }
order[items].menuItem=menu[n-1].menuItem;
order[items].menuPrice=menu[n-1].menuPrice;
items++;
cout<<"Would you like another item?(y/n)? ";
cin>>yesno;
}
}
void showMenu(menuItemType a[],int n)
{int i;
 
    for(i=0;i<n;i++)
         cout<<i+1<<".  "<<setw(16)<<left<<a[i].menuItem<<"$"<<setprecision(2)<<fixed<<a[i].menuPrice<<endl;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.