C Programming Assignment
C Programming Assignment
<Quantity of orders>
<Nmbr_code> <Necessitated units>
...
Every line of the first part relates to an item type and includes the elements below:
1. The number code of the type (unsigned integer).
2. The name of the type (string without spaces).
3. The quantity of units of the item type in storage (unsigned integer).
4. The quantity of ingredient item types that make up the item (unsigned integer). If the
item is a raw material the quantity equals zero (0).
5. As long as the quantity n of ingredient item types (element 4) is greater than zero (0),
the synthesis is also given as a series of n pairs. The first member of every pair is the
number code (unsigned integer) of an item type needed for the construct of the synthetic
item ( for example: a Car whose synthesis consists of glass, wheels and engine is a
synthetic item ). The second member is the quantity of units (unsigned integer) of the
type that are needed for the synthesis of one unit of a synthetic item.
(Next, an input file example is given). This example describes the raw materials, the inter
products and the final product for car manufacturing procedure. In this example there is only
one type of final product. Your program must also function correctly and analogously for
the possibility that the input file contains more ( than 1 ) types of final products. The only
type of final products
included in this example is
the one named Car.
Intermediate products are
of two types ( Wheel and
Engine). The raw
materials are of five types
( Glass, Tire, Rim, Piston,
Belt).
The synthesis of the final
product and the intermediate products can be depicted in the above diagram. In this diagram, on
the left of the name of every item type is its number code. The numbers on the arrows show
how many units are necessary for product synthesis. For example,
for the synthesis of an Engine, 4 Pistons are required and 2 Belts. The numbers in the small
embedded on the upper-left describe the available units in storage. In this particular example,
every one of the raw material types and intermediate products is used for the synthesis of only
one type of product. Your program must function even whenever there is a possibility that
some of the raw materials or intermediate products are used to synthesize more than one
type of products like in the additional example ( at the end ).
Glass 3 0
Tire 5 0
Rim 3 0
Piston 3 0
Belt 2 0
Wheel 10 2 2 1 3 1
Engine 2 2 4 4 5 2
Car 5 3 6 4 7 1 1 6
10
The first part of the input file contains the information of the above diagram and also the
quantity of available units of every item type in storage. For example, the line that describes
the type of items Car is:
8 Car 5 3 6 4 7 1 1 6
Meaning, this type has a number code 8, name Car, there are 5 available units in storage and for
the synthesis of one unit of this type 3 other item types are required. Specifically, 4 units of
type with number code 6, 1 unit of type with number code 7 and 6 units of type with number
code 1. The rest of the lines of the first part of the file are analogously interpreted.
The second part of the file includes information for uncompleted/waiting orders. More
specifically, there is an uncompleted/waiting order of 10 units of type with number code 8.
Output format (dataout.txt)
The output file begins with a line that contains the total quantity of lines that are to be followed.
Next, it includes a line for every item type. Every such line describes one item type and
contains:
the number code of item types
its name
the quantity of units available in storage,
the quantity of units required for the completion of the uncompleted/waiting orders
(based upon information for its synthesis).
Number of material types: <Quantity of item types>
<Nmbr_code>/<Name> - <Quantity in storage> units in stock - <Required quantity for completion of
orders> units needed.
...
Output file
Number of material types: 9
1/Glass - 3 units in stock - 69 units needed.
2/Tire - 5 units in stock - 70 units needed.
3/Rim - 3 units in stock - 70 units needed.
4/Piston - 3 units in stock - 52 units needed.
5/Belt - 2 units in stock - 26 units needed.
6/Wheel - 10 units in stock - 70 units needed.
7/Engine - 2 units in stock - 13 units needed.
8/Car - 5 units in stock - 10 units needed.
9/Truck 2 units in stock 3 units needed.