Dear fellow members,
i have got some information with which i need to create a program, i will be very
greatful if somebody could help me with it. in total there are 6 questions but i have
included 2 below to start off with. the questions do not need to be answered fully
and plus it needs to be very basic C programming. it needs to be programmed in ANSI
C, the program doesnt even neccessarily have to work, but just as long as the main
gist of the objectives are acheived. thank you for your help please forward me any
code.
the information is:
A glazier requires a program which will be used to maintain a set of records Each
record is for a pane of glass fitted at a customers premises. Each pane will be given a
unique record number. Each customer job will be given a unique invoice number. more
than one pane may be charged on the same invoice, records for these panes will have
the same invoice number.
The global program data to be used is as follows:
#define MAXPANES 30
typedef struct pane{
int recno;/*record number/pane number, must be unique within array */
int invoice;/*invoice number*/
float height;/* height of pane in metres */
float width;/* width of pane in metres */
int type; /*number between 0 and 5 indexing types and ppsqm arrays see
below*/
float cost; /*total cost of supply and fitting pane in pounds and pence*/
}PANE;
PANE jobs[MAXPANES]; /*allocates name and memory for jobs array*/
/*types is an array of strings indexed by the type member describing glass types*/
char *types[ ]={"4mm_single","6mm_single", "laminated","toughened",
"patterned", "double"};
/*ppsqm is an array indexed by the type member giving material price of corresponding
typeof glass per square metre*/
float ppsqm[ ] = {4.5, 6.5, 8.5, 7.5, 6.5, 20.0};
***************************************************************************
*please can anybody help me answer the following questions given the above data*
***************************************************************************
1.given the prototype and comment
int load_panes(void); /*loads panes from text file panes.txt */
write the source code for a function which is compatible wit htis prototype and which
reads records from a text file. Each record is followed by newline. spaces exist
between each field. fields are in the same order and types as in the struct pane
declaration. All records present within the text file and all fields in each record must
be input into the appropriate records and fields within the jobs array. the text file
may have any number of records. your function should input this number if there are
less than or exactly 30 records in the file, and it should input the first 30 records
and no more if the number of records in the file is more than 30. Your function
should count the number of records input and return this integer.
2.given the prototype and comment:
void save_panes(int num_panes); /*saves panes records from array into text file
panes.txt*/
write source code for a function which is compatible with this prototype. your
function must open the text file: panes.txt and write the records in text format into
this file. floating point values must be stored to 2 decimal places. the parameter:
num_panes will be a number between 0 and 30 corresponding to the number of records
stored in the lower part of the jobs array. spaces must be output between fields and
newlines between records. your program must report if an error occurs opening the
output file, otherwise it must output the number of records written to the console.