POS system

Hi guys can you help me
this program output is:
F1 carbonarra 2 110
F1 carbonarra 2 110
F1 carbonarra 2 110

but i want it to become like this
F1 carbonarra 6 330

and how can i add or delete an item..

thanks in advance

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include<iostream>
#include<conio.h>
#include<string>
#include<windows.h>
using namespace std;
int order,x;
string codeProduct[100],product[100],codeProduct1[100];
int quantity[1],quantity1[100];
int price[0];
int total;
int main ()
{
cout<<"\n\t\tPPPPPPPPPP         OOOOOOO          SSSSSSSS"<<endl;Sleep(100);
cout<<"\t\tPPPPPPPPPPP      OOOOOOOOOOO       SSSSSSSSSS"<<endl;Sleep(100);
cout<<"\t\tPPPPPPPPPPPP    OOOOO   OOOOO     SSSS    SSSS"<<endl;Sleep(100);
cout<<"\t\tPPPP   PPPPP   OOOOO     OOOOO    SSSS     SSS"<<endl;Sleep(100);
cout<<"\t\tPPPP   PPPPP  OOOOO       OOOOO   SSSS"<<endl;Sleep(100);
cout<<"\t\tPPPP  PPPPP   OOOOO       OOOOO    SSSSSSSSS"<<endl;Sleep(100);
cout<<"\t\tPPPPPPPPPP    OOOOO       OOOOO   SSSSSSSSSSS"<<endl;Sleep(100);
cout<<"\t\tPPPPPPPPP     OOOOO       OOOOO           SSSS"<<endl;Sleep(100);     
cout<<"\t\tPPPP           OOOOO     OOOOO    SSS     SSSS"<<endl;Sleep(100);
cout<<"\t\tPPPP            OOOOO   OOOOO     SSSS    SSSS"<<endl;Sleep(100);
cout<<"\t\tPPPP             OOOOOOOOOOO       SSSSSSSSSS"<<endl;Sleep(100);
cout<<"\t\tPPPP               OOOOOOO          SSSSSSSS"<<endl;Sleep(100);
cout<<"\n\t#######   ###       ###    ######      ###  ### ###    ### ########"<<endl;Sleep(100);
cout<<"\t#######  #####     #####   ### ###     ###  ### ###    ### ###   ###"<<endl;Sleep(100);
cout<<"\t###     ##   ##   ##   ##  ###  ###    ###  ### ###    ### ###   ####"<<endl;Sleep(100);
cout<<"\t#####  ###   ### ###   ### ###   ###   ######## ###    ### #########"<<endl;Sleep(100);
cout<<"\t#####  ###   ### ###   ### ###   ###   ######## ###    ### ###    ###"<<endl;Sleep(100);
cout<<"\t###     ##   ##   ##   ##  ###  ###    ###  ### ###    ### ###    ####"<<endl;Sleep(100);
cout<<"\t###      #####     #####   ### ###     ###  ###  ##    ##  ###    ###"<<endl;Sleep(100);
cout<<"\t###       ###       ###    ######      ###  ###   ######   #########"<<endl;Sleep(100);
system("pause");
system("cls");
cout<<"\n\t#######   ###       ###    ######      ###  ### ###    ### ########"<<endl;
cout<<"\t#######  #####     #####   ### ###     ###  ### ###    ### ###   ###"<<endl;
cout<<"\t###     ##   ##   ##   ##  ###  ###    ###  ### ###    ### ###   ####"<<endl;
cout<<"\t#####  ###   ### ###   ### ###   ###   ######## ###    ### #########"<<endl;
cout<<"\t#####  ###   ### ###   ### ###   ###   ######## ###    ### ###    ###"<<endl;
cout<<"\t###     ##   ##   ##   ##  ###  ###    ###  ### ###    ### ###    ####"<<endl;
cout<<"\t###      #####     #####   ### ###     ###  ###  ##    ##  ###    ###"<<endl;
cout<<"\t###       ###       ###    ######      ###  ###   ######   #########"<<endl;

cout<<"\n\t MENU";
cout<<"\t Code Product"<<"\t\tProduct Name"<<"\t\tProduct Price"<<endl;
cout<<"\tPASTA"<<"\t P1\t "<<"\t\tCarbonara   "<<"\t\tPhp 55.00    "<<endl;
cout<<"\t     "<<"\t P2\t "<<"\t\tSpaghetti   "<<"\t\tPhp 50.00    "<<endl;
cout<<"\t     "<<"\t P3\t "<<"\t\tPalabok     "<<"\t\tPhp 60.00    \n"<<endl;
cout<<"\tPIZZA"<<"\t P4\t "<<"\t\tHawaian     "<<"\t\tPhp 40.00    "<<endl;
cout<<"\t     "<<"\t P5\t "<<"\t\tMeaty       "<<"\t\tPhp 55.00    "<<endl;
cout<<"\t     "<<"\t P6\t "<<"\t\tOverload    "<<"\t\tPhp 70.00    \n"<<endl;
cout<<"      DESSERT"<<"\t P7\t "<<"\t\tMango Float"<<"\t\tPhp 50.00    "<<endl;
cout<<"\t     "<<"\t P8\t "      <<"\t\tBuko Pandan"<<"\t\tPhp 55.00    "<<endl;
cout<<"\t     "<<"\t P9\t "      <<"\t\tHalo-Halo  "<<"\t\tPhp 50.00    "<<endl;
cout<<"\t     "<<"\t P10\t"      <<"\t\tLeche Flan "<<"\t\tPhp 45.00    "<<endl;
cout<<"\n\tHow Many Do You want To Order?:";cin>>order;
 for(x=1;x<=order;x++)
 {system("cls");
  cout<<"\n\t MENU";
  cout<<"\t Code Product"<<"\t\tProduct Name"<<"\t\tProduct Price"<<endl;
  cout<<"\tPASTA"<<"\t F1\t "<<"\t\tCarbonara   "<<"\t\tPhp 55.00    "<<endl;
  cout<<"\t     "<<"\t F2\t "<<"\t\tSpaghetti   "<<"\t\tPhp 50.00    "<<endl;
  cout<<"\t     "<<"\t F3\t "<<"\t\tPalabok     "<<"\t\tPhp 60.00    \n"<<endl;
  cout<<"\tPIZZA"<<"\t F4\t "<<"\t\tHawaian     "<<"\t\tPhp 40.00    "<<endl;
  cout<<"\t     "<<"\t F5\t "<<"\t\tMeaty       "<<"\t\tPhp 55.00    "<<endl;
  cout<<"\t     "<<"\t F6\t "<<"\t\tOverload    "<<"\t\tPhp 70.00    \n"<<endl;
  cout<<"      DESSERT"<<"\t F7\t "<<"\t\tMango Float"<<"\t\tPhp 50.00    "<<endl;
  cout<<"\t     "<<"\t F8\t "      <<"\t\tBuko Pandan"<<"\t\tPhp 55.00    "<<endl;
  cout<<"\t     "<<"\t F9\t "      <<"\t\tHalo-Halo  "<<"\t\tPhp 50.00    "<<endl;
  cout<<"\t     "<<"\t F10\t"      <<"\t\tLeche Flan "<<"\t\tPhp 45.00    "<<endl;
  cout<<"\t*****************************************"<<endl;
  cout<<"\t*IF YOU FINISH TO ORDER: PLS TYPE 'DONE'*"<<endl;
  cout<<"\t*****************************************"<<endl;
  cout<<"\n\t Enter "<<x<< " Code Product:";getline(cin,codeProduct[x]);
  cout<<" ";getline(cin,codeProduct[x]);
  if(codeProduct[x]=="Done"||codeProduct[x]=="done"||codeProduct[x]=="DONE")
  {
   x=order;
   
  }
  else
  { cout<<endl;
   cout<<"\tEnter Quantity of "<< codeProduct[x]<<":";cin>>quantity1[x];
   quantity[x]=quantity1[x];
   if(codeProduct[x]=="F1"||codeProduct[x]=="f1")
   {codeProduct1[x]="F1";
    price[x] = 55*quantity[x];
    product[x] = "Carbonara";
   }
   else if(codeProduct[x]=="F2"||codeProduct[x]=="f2")
   {codeProduct1[x]="F2";
    price[x] = 50*quantity[x];
    product[x] = "Spaghetti";
   }
   else if(codeProduct[x]=="F3"||codeProduct[x]=="f3")
   {codeProduct1[x]="F3";
    price[x] = 60*quantity[x];
    product[x] = "Palabok  ";
   }
   else if(codeProduct[x]=="F4"||codeProduct[x]=="f4")
   {codeProduct1[x]="F4";
    price[x] = 50*quantity[x];
    product[x] = "Hawaian Pizza";
   }
   else if(codeProduct[x]=="F5"||codeProduct[x]=="f5")
   {codeProduct1[x]="F5";
    price[x] = 55*quantity[x];
    product[x] = "Meaty Pizza";
   }
   else if(codeProduct[x]=="F6"||codeProduct[x]=="f6")
   {codeProduct1[x]="F6";
    price[x] = 70*quantity[x];
    product[x] = "Overload Pizza";
   }
   else if(codeProduct[x]=="F7"||codeProduct[x]=="f7")
   {codeProduct1[x]="F7";
    price[x] = 50*quantity[x];
    product[x] = "Mango Float";
   }
   else if(codeProduct[x]=="F8"||codeProduct[x]=="f8")
   {codeProduct1[x]="F8";
    price[x] = 55*quantity[x];
    product[x] = "Buko Pandan";
   }
   else if(codeProduct[x]=="F9"||codeProduct[x]=="f9")
   {codeProduct1[x]="F9";
    price[x] = 50*quantity[x];
    product[x] = "Halo-Halo";
   }
   else if(codeProduct[x]=="F10"||codeProduct[x]=="f10")
   {codeProduct1[x]="F10";
    price[x] = 55*quantity[x];
    product[x] = "Leche Flan";
   }
   else
   {
       cout<<"Error"<<endl;
       system("pause");
       return 0;
   }
  }
 }
 system("cls");
 for(x=1;x<=order;x++)
 {
  cout<<codeProduct1[x]<<"\t"<<product[x]<<"\t"<<quantity[x]<<"\tPhp "<<price[x]<<endl;
  total = total+price[x];
 }
 cout<<total;
getch ();
return 0;
}
Last edited on
You will have to loop over the order to check for duplicate entries.
If you find a duplicate, you will have to combine the quantities and the price and you will have to make sure that one of the entries is not used anymore (e.g. set price and quantity to 0).

Something like this maybe:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 system("cls");
 // Begin of modification
 for(x=1;x<=order;x++)
 {
  for (int y=2;x<=order;x++)
  {
      if (codeProduct1[x] == codeProduct1[y]) // somebody placed two orders instead of entering a higher quantity
      {
          quantity[x] = quantity[x] + quantity[y];
          price[x] = price[x] + price[y];
          quantity[y] = 0;
          price[y] = 0;
      }
  }
 }
 // End of modification
 for(x=1;x<=order;x++)
 {
  // Begin of modification
  if (quantity[x] > 0)
  // End of modification
  cout<<codeProduct1[x]<<"\t"<<product[x]<<"\t"<<quantity[x]<<"\tPhp "<<price[x]<<endl;


And in general:
- why do you store almost everything in arrays?
- you should use functions for a program like this:
For example a function to order a product + quantity, a function to output the list at the end
-
Last edited on
Thanks.. :-) it was a great help

but there is one problem

if I enter F1,F2,F1

the ouput is
F1 Carbonarra 2 110
F1 Cabonarra 2 110

but when i input: F1, F1, F2

F1 Carbonarra 4 220
F2 Spaghetti 2 100
Topic archived. No new replies allowed.