Im confused on how to make a file and import it

you are to read all records from a file named data.txt into an
appropriately named and constructed array of structs. You will not know exactly how many records there will be in the file but you do know that there will be no more than 1000.

The data.txt file will consist of records of the following format:
Sales person ID (string),
item1 ID # (string),
item1 quantity (integer),
item1 price (double),
item2 ID # (string),
item2 quantity (integer)
, item2 price (double),
item3 ID # (string),
item3 quantity (integer),
item3 price (double),
item4 ID # (string),
item4 quantity (integer),
item4
price (double),
order date (string -- format: mm/dd/yyyy),
contact email (string)
Once all records are read into the array of structs, sort the array in ascending order based
on order date.
Include in your struct one more field than the number of fields being read in from a record.
This extra field will be a CALCULATED field. You will not read data into this field but you
will instead assign a value to this field for every record by performing the following
calculation: max (itemI quantity * itemI price) for all possible values of I (1, 2, 3,or 4).
[for example if the quantities and prices of the items were 3 and 5.1, 2 and 4.95, 0 and
11.99, 10 and 4.05 for some record, then the max of the quantity/price products would be
40.5 for this record and this is the value that would be assigned to the final field for this
record.]
Finally you will create a report file, named report.txt, which contains a listing of all of the
records in the array that meet the following criteria: the max field value is greater than or
equal to 150 but less than or equal to 375.
You will need to create your own data.txt file for the purposes of running and testing your
code.


Last edited on
Topic archived. No new replies allowed.