Need help with C++ program. A big-food company located in Norfolk, VA tries to r
ID: 3885320 • Letter: N
Question
Need help with C++ program.
A big-food company located in Norfolk, VA tries to run its main storehouse perfectly. 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 Tidewater area (Norfolk, Chesapeake, Suffolk, Portsmouth, 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. A Record contains many fields, where fields are separated by a comma, as follows:
Shipments.txt:
Name of food item
Expiration Date (month:day:year)
Size of the Box (length:width:height) in inches
Weight of the box in pounds
Best Storage Method (refrigerate “R”, freeze “F”, do not refrigerate “D”)
Date Shipment Received (month:day:year)
Price of the Item (dollar.cent)
Customers.txt:
Name of customer (small business)
Location (city name) of business
Distance from the Storehouse in miles
Orders.txt:
Name of customer (small business)
Name of item needed
Number of boxes
Total cost (dollar.cent)
Date (month:day:year) order is placed
Task: Your task for this assignment is to write a C++ program to help the company run its warehouse. Use struct to represent the elements of the arrays. Name the arrays shipments, customers, orders. As a result, the data will be read into arrays of structs. The size of each array cannot be fixed; instead, the size should be read from the corresponding data file except for shipments for which it is 20. All elements of an array are records read from a single file.
The main() function of your program should be very simple. The main function should be a collection of variables declaration and functions call. You will need to use three different functions to read the data from the three files. You can add more functions if you want. You must provide the user with a capability of printing the data of any record (shipment, customer, and orders) on the computer monitor. You must also provide a function to search for a specific item in the shipments array. The search should be done by the item name and from the computer monitor.
Do not use global variables except for the shipments struct array of size 20. Apart from this you can use at most one global variable
Files:
Shipments.txt
15
Apples 01:30:2015 10:11:12 20 R 01:21:2015 12.00
Bananas 10:25:2015 12:11:19 25 R 01:21:2015 15.00
Apples 02:25:2015 50:41:62 20 D 01:25:2015 40.00
PineApple 02:02:2015 05:04:60 40 R 01:02:2015 55.00
Grapes 03:03:2015 25:25:25 55 D 01:20:2014 64.00
Tomato 04:04:2015 30:30:30 18 D 01:20:2015 44.00
Potato 05:06:2015 25:25:25 66 D 01:25:2014 34.00
Lays 10:01:2016 10:90:60 25 D 10:22:2013 12.00
EggPlant 04:25:2015 55:49:60 76 R 01:25:2015 11.00
Oranges 07:01:2015 50:41:62 55 R 12:20:2014 16.00
Kiwi 02:02:2015 05:41:06 88 D 12:15:2014 14.00
Chicken 09:25:2016 05:04:06 99 F 10:10:2014 80.00
Pears 02:25:2015 26:41:36 64 R 01:23:2015 21.00
Carrot 12:02:2015 26:36:26 54 D 01:20:2015 32.00
Plum 12:02:2015 05:04:06 55 D 01:29:2015 20.00
Customers.txt
15
Andrew Norfolk 20
Anne Suffolk 30
Bruce Chesapeake 36
Charlie Hampton 40
Charry Norfolk 15
Finn VaBeach 24
Gracy Hampton 39
Ben Suffolk 25
Vijay Chesapeake 37
Jay Suffolk 28
Sajan Hampton 48
Rishi Chesapeake 39
John Suffolk 28
Smith Hampton 49
Pepp Chesapeake 32
Orders.txt
15
Andrew Apples 3 23.00 01:25:2015
Bruce Bananas 5 32.20 02:20:2015
Finn PineApple 8 55.55 10:02:2014
Gracy Grapes 9 47.74 12:20:2014
Smith Apples 2 80.00 11:02:2014
Pepp Bananas 5 10.10 01:12:2015
Smith PineApple 7 50.20 01:23:2015
Jay Carrot 8 90.09 01:29:2015
Charlie Apples 7 20.85 01:23:2015
Rishi Potato 2 29.99 10:12:2014
John Plum 9 55.98 01:02:2015
Ben PineApple 10 55.99 09:13:2014
Andrew Apples 11 89.55 12:18:2013
Pepp Chicken 15 99.22 11:20:2014
Anne Bananas 5 87.00 01:13:2015
Example Output
Shipments Food ItemExp Date Box Size Weight Storage Received date Price 12.00 15.00 40.00 55.00 64.00 44.00 34.00 12.00 11.00 16.00 14.00 80.00 21.00 32.00 20.00 Apples Bananas Apples 101:30:2015 10:11:12 20 10:25:2015 12:11:1925 02 :25:2015 50:41:62 20 ineApple 02:02:2015 05:04:60 40 03:03:2015 25:25:25 55 104:04:2015 30:30:30 18 05 06:2015 25:25:25 66 10:01:2016 10:90:625 04:25 2015 55:49:6 76 07:01:201550:41:6255 02:02:2015 05:41:06 88 09:25:2016 05:04:06 99 02 :25 2015 26:41:36 64 12:02 2015 26:36:26 54 12:02:2015 05:04:06 55 1 21:2015 01 21:2015 01 25:2015 01 02 2015 01 20 2014 01:20:2015 01 25:2014 10:22 2013 01:25:2015 12:20 2014 12:15:2014 10:10:2014 01 23:2015 01 20:2015 1:29:2015 Grapes omato Potato Lays EggPlant Oranges Kivi Chicken Pears Carrot Customers Customer Name City Distance Norfolk Suffolk Chesapeake Hampton Norfolk UaBeach Hampton Suffolk Chesapeake Suffolk Hampton Andrew Anne Bruce Charlie Charry 20 30 Gracy Ben 28 48 Sajan Rishi i Chesapeake 28 Suffolk Hampton Chesapeake SmithExplanation / Answer
#include <stdio.h>
int addNumbers(int a, int b);
int main()
{
int n1,n2,sum;
printf("Enters two numbers: ");
scanf("%d %d",&n1,&n2);
sum = addNumbers(n1, n2);
printf("sum = %d",sum);
return 0;
}
int addNumbers(int a,int b)
{
int result;
result = a+b;
return result;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.