HELP!!!! WILL AWARD MAX POINTS FOR CORRECT ANSWER!!! The company receives new sh
ID: 638966 • Letter: H
Question
HELP!!!! WILL AWARD MAX POINTS FOR CORRECT ANSWER!!!
The company receives new shipments every day at the storehouse. The company redistributes the shipment to a set of customers (small businesses) located in the tide water area (Norfolk, Chesapeake, Suffolk, Portsmouth, Suffolk, Va.Beach, and Hampton). The data at the storehouse are saved into records in three text files. The first line of each file shows the number of records in the file. Record contains many fields, where fields are separated by a space, as follow:
Shipments.txt:
1.Name of food item
2. Expiration Date (month:day:year)
3. Size of the Box (length:width:height) in inches
4. Weight of the box in pounds,
5. Best Storage Method (refrigerate
Explanation / Answer
Program Code:
// WareHouse.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;
const int size=20;
struct shipment
{
char foodItemName[20];
char expDate[20];
char box_size[20];
double box_weight;
char store_method;
char shipment_received[20];
char item_price[20];
}ship;
struct customer
{
int size;
char customerName[20];
char location[20];
double distance;
}cust;
struct order
{
int size;
char customerName[30];
char itemName[20];
int num_boxes;
char totalCost[20];
char date[20];
}ord;
struct storehouse
{
shipment *ship;
customer *cust;
order *ord;
};
void readShipments(storehouse s);
int readCustomers(storehouse s);
int readOrders(storehouse s);
void printShipments(storehouse s);
void printCustomer(storehouse s, int length);
void printOrders(storehouse s, int length);
void searchItemname(storehouse s);
int main()
{
int len1, len2;
storehouse s;
s.ship=new shipment[size];
readShipments(s);
cout<<"The shipment details: "<<endl;
printShipments(s);
len1=readCustomers(s);
len2=readOrders(s);
printCustomer(s, len1);
printOrders(s, len2);
searchItemname(s);
system("pause");
return 0;
}
void readShipments(storehouse s)
{
ifstream shipfile("Shipments.txt");
int count=0;
if(shipfile)
{
while(!shipfile.eof())
{
shipfile>>s.ship[count].foodItemName;
shipfile>>s.ship[count].expDate;
shipfile>>s.ship[count].box_size;
shipfile>>s.ship[count].box_weight;
shipfile>>s.ship[count].store_method;
shipfile>>s.ship[count].shipment_received;
shipfile>>s.ship[count].item_price;
count++;
}
}
shipfile.close();
}
int readCustomers(storehouse s)
{
int length;
ifstream custfile("Customers.txt");
int count=0;
if(custfile)
{
custfile>>length;
s.cust=new customer[length];
cout<<length;
while(!custfile.eof())
{
custfile>>s.cust[count].customerName;
custfile>>s.cust[count].location;
custfile>>s.cust[count].distance;
count++;
}
}
cout<<s.cust[0].customerName;
custfile.close();
return length;
}
int readOrders(storehouse s)
{
int length;
ifstream orderfile("Orders.txt");
int count=0;
if(orderfile)
{
orderfile>>length;
s.ord=new order[length];
while(!orderfile.eof())
{
orderfile>>s.ord[count].customerName;
orderfile>>s.ord[count].itemName;
orderfile>>s.ord[count].num_boxes;
orderfile>>s.ord[count].totalCost;
orderfile>>s.ord[count].date;
count++;
}
}
orderfile.close();
return length;
}
void printShipments(storehouse s)
{
cout<<"The shipment details: "<<endl;
for(int i=0;i<size;i++)
{
cout<<s.ship[i].foodItemName<<" ";
cout<<s.ship[i].expDate<<" ";
cout<<s.ship[i].box_size<<" ";
cout<<s.ship[i].box_weight<<" ";
cout<<s.ship[i].store_method<<" ";
cout<<s.ship[i].shipment_received<<" ";
cout<<s.ship[i].item_price<<" ";
cout<<endl;
cout<<endl;
}
}
void printCustomer(storehouse s, int length)
{
cout<<"The customers details: "<<endl;
for(int i=0;i<length;i++)
{
cout<<s.cust[i].customerName<<" ";
cout<<s.cust[i].location<<" ";
cout<<s.cust[i].distance<<" ";
cout<<endl;
}
}
void printOrders(storehouse s, int length)
{
cout<<"The orders details: "<<endl;
for(int i=0;i<length;i++)
{
cout<<s.ord[i].customerName<<" ";
cout<<s.ord[i].itemName<<" ";
cout<<s.ord[i].num_boxes<<" ";
cout<<s.ord[i].totalCost<<" ";
cout<<s.ord[i].date<<" ";
cout<<endl;
}
}
void searchItemname(storehouse s)
{
char item[20];
cout<<"Enter the name of the item to search: ";
cin>>item;
for(int i=0;i<size;i++)
{
if(item==s.ship[i].foodItemName)
{
cout<<s.ship[i].foodItemName<<" ";
cout<<s.ship[i].expDate<<" ";
cout<<s.ship[i].box_size<<" ";
cout<<s.ship[i].box_weight<<" ";
cout<<s.ship[i].store_method<<" ";
cout<<s.ship[i].shipment_received<<" ";
cout<<s.ship[i].item_price<<" ";
cout<<endl;
cout<<endl;
}
}
}
------------------------------------------------------------------------------------------------------------------------------
Sample Input files:
Shipments.txt:
Rice 12:24:2015 20:30:20 500.50 D 01:31:2015 1500:30
Fish 06:30:2015 10:20:30 150.00 F 01:25:2015 3000:00
Spinach 03:01:2015 10:10:10 50.00 R 01:20:2015 500:00
Wheat 12:31:2015 20:30:20 1500.50 D 01:31:2015 2500:30
Prawns 05:30:2015 10:20:30 150.00 F 01:25:2015 3000:00
Radish 03:01:2015 20:10:40 500.00 R 12:20:2014 1500:00
Maze 12:24:2015 20:30:20 500.50 D 01:31:2015 1000:30
Carrot 06:30:2015 10:20:30 150.00 R 01:25:2015 3000:00
Grapes 03:01:2015 20:30:50 50.00 R 01:20:2015 500:00
Apples 12:31:2015 20:30:20 1500.50 R 01:31:2015 2500:30
Mangoes 05:30:2015 50:20:30 1550.00 R 01:25:2015 3000:00
Cereals 03:01:2015 20:20:40 500.00 D 01:20:2015 500:00
Meat 03:20:2015 40:30:50 2000.00 F 01:27:2015 5000:30
Cheese 12:31:2016 50:50:50 250.00 R 01:30:2015 3000:00
Olives 12:31:2015 20:30:20 1500.50 R 01:31:2015 2500:30
Ginger 06:30:2015 10:20:30 150.00 D 01:25:2015 3000:00
Potatoes 03:01:2015 20:20:40 500.00 D 01:20:2015 500:00
CocoBeans 12:31:2015 20:30:20 1500.50 D 01:31:2015 2500:30
Garlic 06:30:2015 10:20:30 150.00 D 01:25:2015 3000:00
Pork 03:01:2015 20:20:40 500.00 F 01:20:2015 500:00
Customers.txt:
7
Kite&Kelly Chesapeake 15.00
MacDonals Suffolk 10.00
Cadbury&Co Norfolk 50.00
Lenen&Giner Va.Beack 20.00
Pette&Parker Hampton 60.00
GoGoBeackPark Portsmouth 55.00
HellsKitchen Suffolk 34.00
Orders.txt:
5
Cadbury&Co CocoBeans 50 125000:00 12:28:2014
HellsKitchen Spinach 10 5000:00 01:02:2015
GoGoBeackPark Meat 20 100000:00 12:29:2014
Lenen&Giner Fish 25 75000:00 01:03:2015
MacDonals Olives 30 75000:00 01:02:2015
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.