You are to write a program to produce a report on the invent
You are to write a program to produce a report on the inventory for some warehouses. The input for this program is found in several files. Each file is maintained by different departments within the company and each department uses a different index to reference the data (i.e. some use Item_Number others use Item_Name). One department uses the concatenation of the Item_Name and Item_Number.
You are to read in the data from the different files, combine all the data, and print out a single report showing the inventory for each warehouse. The input data is WLL1.txt ...WLL2.txt ...WLL3.txt ...WLL4.txt\'.
Files Contains the following information:
WLL1.txt Item_Number Item_Name
WLL2.txt Item_Number WareHouse_Name
WLL3.txt Item_Name quanity
WLL4.txt Item_NameItem_Number WholeSale-Price Markup_value
You are to create an array of structures to store Ware House information, sorted by WareHouse and within each warehouse sort by Item_Number. Print out a report for each warehouse.
Output Format: Output information by WareHouse name and by Item-Number is in ascending order.
Ware House Name 1
Item-Number Item_Name Quanity Wholesale Price MarkUpValue Retail Value
1821 Whoseys 10 25.00 75% 437.50
8321 SkyLight 3 150.00 50% 675.00
...
Total XXXX.XX
Ware House Name 2
Item-Number Item_Name Quanity Wholesale Price MarkUpValue Retail Value
1821 Whoseys 10 25.00 75% 437.50
8321 SkyLight 3 150.00 50% 675.00
...
Total XXXX.XX
Requirements: Your program will use an array of structures to store the information.
Solution
#include<iostream>
#include<fstream.h>
#include<conio.h>
#include<iomanip>
#include <algorithm>
using namespace std;
typedef struct inform
{
int item_num;
string item_name;
string ware_name;
int quant;
float price;
int value;
}my_inform;
main()
{
my_inform arr[10000];
string fname;
cout<<\"enter 1st file name \"<<endl;
cin>>fname;
ifstream myfile1(fname.c_str());
int i=0;
int total;
if(myfile1.is_open())
{
int num;
string name;
while(myfile1>>num>>name)
{
arr[i].item_num=num;
arr[i].item_name=name;
i++;
}
total=i;
}
else
cout<<\"can\'t open file\"<<endl;
cout<<\"enter 2nd file name\"<<endl;
cin>>fname;
ifstream myfile2(fname.c_str());
if(myfile2.is_open())
{
int num;
string name;
while(myfile2>>num)
{
getline(myfile2,name);
//cout<<num<<\" \"<<name<<endl;
for(int j=0;j<total;j++)
{
if(arr[j].item_num==num)
{
arr[j].ware_name=name;
break;
}
}
}
}
else
cout<<\"can\'t open file\"<<endl;
cout<<\"enter 3rd file name\"<<endl;
cin>>fname;
ifstream myfile3(fname.c_str());
if(myfile3.is_open())
{
int quantity;
string name;
while(myfile3>>name>>quantity)
{
for(int j=0;j<total;j++)
{
if(arr[j].item_name==name)
{
arr[j].quant=quantity;
break;
}
}
}
}
else
cout<<\"can\'t open file\"<<endl;
cout<<\"enter 4th file name\"<<endl;
cin>>fname;
ifstream myfile4(fname.c_str());
if(myfile4.is_open())
{
float pr;
string val;
string mixed;
while(myfile4>>mixed>>pr>>val)
{
string temp_name=\"\";
i=0;
while(!isdigit(mixed[i]))
{
temp_name+=mixed[i];
i++;
}
i=0;
int num=0;
while(isdigit(val[i]))
{
num=num*10+val[i]-\'0\';
i++;
}
for(int j=0;j<total;j++)
{
if(arr[j].item_name==temp_name)
{
arr[j].price=pr;
arr[j].value=num;
break;
}
}
}
}
else
cout<<\"can\'t open file\"<<endl;
my_inform new_arr[total];
bool visited[total];
for(i=0;i<total;i++)
visited[i]=0;
int k;
for(i=0;i<total;i++)
{
k=0;
if(!visited[i])
{
for(int j=0;j<total;j++)
{
if(!visited[j] && arr[i].ware_name==arr[j].ware_name)
{
new_arr[k].item_num=arr[j].item_num;
new_arr[k].item_name=arr[j].item_name;
new_arr[k].quant=arr[j].quant;
new_arr[k].value=arr[j].value;
new_arr[k].price=arr[j].price;
visited[j]=1;
k++;
}
}
for(int m=0;m<k;m++)
{
for(int n=m+1;n<k;n++)
{
if(new_arr[m].item_num>new_arr[n].item_num)
{
int temp=new_arr[m].item_num;
new_arr[m].item_num=new_arr[n].item_num;
new_arr[n].item_num=temp;
string temp1=new_arr[m].item_name;
new_arr[m].item_name=new_arr[n].item_name;
new_arr[n].item_name=temp1;
int temp3=new_arr[m].quant;
new_arr[m].quant=new_arr[n].quant;
new_arr[n].quant=temp3;
int temp4=new_arr[m].value;
new_arr[m].value=new_arr[n].value;
new_arr[n].value=temp4;
float temp5=new_arr[m].price;
new_arr[m].price=new_arr[n].price;
new_arr[n].price=temp5;
}
}
}
double sum_total=0;
cout<<\"Ware-House \"<<arr[i].ware_name<<endl;
cout<<\"Item-Number Item_Name Quanity Wholesale Price MarkUpValue Retail Value\"<<endl;
for(int l=0;l<k;l++)
{
sum_total+=(new_arr[l].price*new_arr[l].quant*arr[l].value)/(double)100;
cout<<new_arr[l].item_num<<\" \"<<setw(18) <<new_arr[l].item_name<<\" \"<<setw(5)<<new_arr[l].quant<<\" \"<<setw(5)<< new_arr[l].price<<\" \"<<setw(5) <<new_arr[l].value<<\"% \"<<setw(10) <<(new_arr[l].price*new_arr[l].quant*arr[l].value)/(double)100<<endl;
}
cout<<\" Total: \"<<sum_total<<endl;
}
}
}
here is the output file :
Ware-House West Coast
Item-Number Item_Name Quanity Wholesale Price MarkUpValue Retail Value
1090 StuffedStuff-z 7 16.56 95% 70.7112
1360 Woosies-w 21 54.12 63% 1079.69
3310 Galixies-r 5 39.79 61% 23.874
3985 TightShoes-p 29 12.14 52% 278.127
4558 Toosies-m 19 35.71 92% 196.762
5047 Gowns-r 1 71.19 90% 44.8497
5364 TenEShoe-s 1 76.39 27% 61.8759
5795 Whiskers-a 18 88.12 66% 1284.79
6092 CutThroat-l 8 84.89 66% 346.351
6415 MacARainy-y 16 29.48 4% 160.371
6571 HailBock-o 16 47.79 81% 627.005
8664 TwoB1Ask1-x 3 0 0% 0
9651 Hallies-l 13 79.95 34% 51.9675
Total: 4226.38
Ware-House Swappy South
Item-Number Item_Name Quanity Wholesale Price MarkUpValue Retail Value
1096 Woosies-c 1 37.94 69% 23.1434
1546 TenEShoe-d 19 44.35 56% 800.517
1935 CutThroat-z 0 86.98 95% 0
2016 Toosies-x 4 39.18 26% 123.809
3783 Galixies-v 1 13.96 82% 4.0484
5057 HailBock-g 16 47.91 24% 482.933
5211 Hallies-i 21 49.18 51% 836.552
5862 TwoB1Ask1-q 26 0 0% 0
6543 Gowns-c 10 26.42 95% 134.742
6962 StuffedStuff-p 13 77.85 25% 344.097
7463 Whiskers-v 29 81.03 49% 1926.89
7948 MacARainy-c 17 19.3 4% 98.43
8100 TightShoes-k 25 77.88 12% 97.35
Total: 4872.52
Ware-House Desert West
Item-Number Item_Name Quanity Wholesale Price MarkUpValue Retail Value
1156 Galixies-s 8 42.79 59% 208.815
1275 TwoB1Ask1-m 10 0 0% 0
1636 TightShoes-n 10 32.68 58% 39.216
2285 Gowns-u 23 24.22 37% 440.077
2347 StuffedStuff-a 4 90.42 69% 104.887
3390 Toosies-a 5 78.78 79% 248.157
5589 MacARainy-t 6 63.83 41% 310.214
6190 Woosies-p 23 22.33 29% 416.008
6936 HailBock-p 2 81.6 42% 83.232
8137 TenEShoe-k 3 67.35 67% 68.697
8312 Whiskers-g 23 71.11 93% 1341.13
9561 CutThroat-k 5 82.97 81% 124.455
9667 Hallies-x 26 41.15 18% 53.495
Total: 3438.39
Ware-House Great Lakes
Item-Number Item_Name Quanity Wholesale Price MarkUpValue Retail Value
1094 Galixies-u 8 90.25 63% 440.42
1562 Toosies-o 25 11.18 89% 265.525
1623 HailBock-q 18 47.52 77% 102.643
2099 TwoB1Ask1-r 23 0 0% 0
2683 Gowns-o 6 77.62 9% 135.059
3192 StuffedStuff-j 18 91.13 72% 1033.41
4974 CutThroat-x 11 11.11 81% 98.9901
6179 TightShoes-l 20 93.67 46% 1517.45
7294 TenEShoe-t 16 87.64 93% 715.142
7323 Woosies-e 25 94.36 65% 802.06
7381 MacARainy-h 22 34.61 82% 624.364
8013 Hallies-w 25 34.46 47% 258.45
9287 Whiskers-m 2 14.72 26% 1.472
Total: 5613.88