-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSTORE.CPP
59 lines (56 loc) · 1.39 KB
/
STORE.CPP
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
#include<iostream.h>
#include<conio.h>
#include<fstream.h>
#include<stdlib.h>
void additem(int n)
{
char trno[20], itna[100];
float qt;
ofstream f1[50];
for(int i=n;i<=n;i++)
{
f1[i].open("store", ios::app);
cout<<"Enter Truck Number: "; cin>>trno; f1[i]<<trno<<" ";
cout<<"Enter Item name: "; cin>>itna; f1[i]<<itna<<" ";
cout<<"Enter Quantity in kg: "; cin>>qt; f1[i]<<qt<<endl;
f1[i].close();
}
}
void showdata(int m)
{
ifstream ff[50];
char trno[20]; char itna[100]; float qt;
cout<<" ________________________________________ "<<endl;
cout<<"| TRUCK_NUM | ITEM_NAME | QUANTITY |"<<endl;
cout<<"|----------------------------------------|"<<endl;
for(int i=0; i<m; i++)
{
ff[i].open("store");
ff[i]>>trno; ff[i]>>itna; ff[i]>>qt;
cout<<"| "<<trno<<" | "<<itna<<" | "<<qt<<" |"<<endl;
ff[i].close();
}
cout<<"|________________________________________|"<<endl;
}
int main()
{
int op,c=0;
char o;
clrscr();
do
{
cout<<"Enter 1: for add for register new truck."<<endl;
cout<<"Enter 2: for see the list of Items."<<endl;
cout<<"Enter your option: "; cin>>op;
switch(op)
{
case 1: {additem(c); c++;} break;
case 2: showdata(c); break;
default: cout<<"Please enter a valid number!!"<<endl;
}
cout<<"Do you want to continue? (Y/N): "; cin>>o;
}
while(o=='Y' || o=='y');
getch();
return 0;
}