Question: The three files needed for this project are listed below the instructions. Please do this in C Programming. Three files needed for project: lab10_main.c (THIS

The three files needed for this project are listed below the instructions. Please do this in C Programming.

The three files needed for this project are listed below the instructions.Please do this in C Programming. Three files needed for project: lab10_main.c(THIS IS THE ONLY FILE THAT NEEDS TO BE MODIFIED) #include #include

Three files needed for project:

lab10_main.c (THIS IS THE ONLY FILE THAT NEEDS TO BE MODIFIED)

#include

#include

#include

#include "lab10.h"

double computeAverageBalance(struct cellData list[], int listsize);

double ComputeAverageLastMonthPayment(struct cellData ARlist[], int

listsize);

void sortByState(struct cellData ARlist[], int listsize);

double computeAverageLastMonthPayment(char *list[], int listsize);

void sortListByState(char * list[], int listsize);

/*

The program consists of an array list[], this array is an array of

pointers which points to strings.

Each string has the following format :

Name^Account Number^STATE^Area Code^Mobile Number^Balance

Example

Brian King^2134^IN^317^3411122^245.67

Remember everything is stored as a string.

The information conveyed concerning: the account number is unique and it

is 3 or 4 digits, the state is a two character abbreviation, the area code

is 3 digits, the mobile number is 7 digits and the balance is a floating

value

*/

int main()

{

char * list[25]={NULL};

struct cellData STRlist[25]={0};

int seed=715;

int i,listsize;

listsize= generate_list(list, seed);

printf(" original list *************** ");

for(i=0;i

printf("%s ",list[i]);

printf(" ");

sortListByState(list, listsize);

for(i=0;i

printf("%s ",list[i]);

printf(" ");

printf("the average balance is %.2lf ",

computeAverageLastMonthPayment(list, listsize));

quit(list, listsize);

listsize= generate_Structlist(STRlist, seed);

printf(" original list *************** ");

for(i=0;i

printf("%24s %5s %2s %3s %7s %7.2f %7.2lf ",

STRlist[i].Name, STRlist[i].account, STRlist[i].state,

STRlist[i].areaCode, STRlist[i].mobileNumber, STRlist[i].lastmonthpayment,

STRlist[i].balance);

printf(" ");

//sort by cell data balance

sortByState(STRlist, listsize);

for(i=0;i

printf("%24s %5s %2s %3s %7s %7.2f %7.2lf ",STRlist[i].Name,

STRlist[i].account, STRlist[i].state, STRlist[i].areaCode,

STRlist[i].mobileNumber,STRlist[i].lastmonthpayment, STRlist[i].balance );

printf(" ");

printf("the average balance is %.2lf ",

computeAverageBalance(STRlist, listsize));

}

double computeAverageBalance(struct cellData list[], int listsize)

{

return -1.0;

}

double ComputeAverageLastMonthPayment(struct cellData ARlist[], int

listsize)

{

return -1.0;

}

void sortByState(struct cellData ARlist[], int listsize)

{

}

double computeAverageLastMonthPayment(char *list[], int listsize)

{

return -1.0;

}

void sortListByState(char * list[], int listsize)

{

}

------------------------------------------------------

lab10.c

#include

#include "lab10.h"

#define NUMBER_NAME 25

#define UNOCCUPIED 0

char *name_source[]={"Horace Greeley", "Sigourney Weaver", "Wendy Morse",

"Cora Simmons", "Phil Donahue", "Dan Crane", "Willie Daniels", "Carl

Lewis","Joe Crabb", "Buster Keaton", "Dawn Harris", "Rene Williamson",

"Pat Lane", "Jose Richards", "Edward Morris", "Nathan Nevins", "John Doe",

"Jane Eyre", "Wednesday Adams", "Annette Wendt", "Yannick Noah",

"Christopher Columbus", "George Sims", "Anna Washington", "Marie Curie",

"Rhonda White", "Susan Nash", "Mary Wright", "Lily Langely","John

Thompson", "Ray Reynolds"};

char *acct_source[]={"122", "3431", "1234", "613", "4112", "122", "245",

"908","1091", "1092", "1090", "100", "344", "688", "1331", "5678", "8777",

"3344", "2222", "3056" , "900", "4021", "9001", "1059", "8771", "9883",

"4447", "2332","5555", "1111"};

char *state[]={ "IN", "IL", "NY", "MD", "NC", "VA", "NJ"};

char * mobile_number_source[]={ "2113344", "6889999", "9781234",

"4445555", "2345678", "3121131", "3121131","3121131",

"3121101","9121131","3121131",

"3121131","4321131","3189001","9121131","3121131",

"3121131","3121131","8121101","4121131","5121131",

"6421131","2521131","2031101","1021131" };

char * area_code[]={ "317","345", "214", "711", "812", "753", "721",

"616", "154", "393", "186", "277"};

char * balance[]={ "832.45","100.13", "650.34", "394", "802.3", "71.4",

"7.4", "6.80", "59.45", "93.22", "86.67", "77.23"};

char * lastmonth[] = { "0.00", "32.15","100.09", "65.24", "200.23",

"98.17"};

int acct_position[NUMBER_NAME]={UNOCCUPIED};

int name_position[NUMBER_NAME]={UNOCCUPIED};

int mobile_number_position[NUMBER_NAME]={UNOCCUPIED};

int generate_list(char ** list, int K)

{

char buffer[300];

int j,i,listsize;

srand(K);

listsize = rand()%10 +16;

for(i=0;i

{

memset(buffer, 0, 200);

j=rand()%25;

while(name_position[j]!= UNOCCUPIED)

j=rand()%25;

name_position[j]++;

strcpy(buffer, name_source[j]);

strcat(buffer, "^");

j=rand()%25;

while(acct_position[j]!= UNOCCUPIED)

j=rand()%25;

acct_position[j]++;

strcat(buffer, acct_source[j]);

strcat(buffer, "^");

j=rand()%7;

strcat(buffer, state[j]);

strcat(buffer, "^");

j=rand()%12;

strcat(buffer, area_code[j]);

strcat(buffer, "^");

j=rand()%25;

while(mobile_number_position[j]!= UNOCCUPIED)

j=rand()%25;

mobile_number_position[j]++;

strcat(buffer, mobile_number_source[j]);

strcat(buffer, "^");

j = rand() % 6;

strcat(buffer, lastmonth[j]);

strcat(buffer, "^");

j=rand()%12;

strcat(buffer, balance[j]);

list[i]=(char *)malloc(strlen(buffer)+5);

strcpy(list[i], buffer);

}

return listsize;

}

int generate_Structlist(struct cellData* list, int K)

{

char buffer[300];

int j,i,listsize;

srand(K);

memset(acct_position, 0, sizeof(int)*NUMBER_NAME);

memset(name_position, 0, sizeof(int)*NUMBER_NAME);

memset(mobile_number_position, 0, sizeof(int)*NUMBER_NAME);

listsize = rand()%10 +16;

for(i=0;i

{

j=rand()%25;

while(name_position[j]!= UNOCCUPIED)

j=rand()%25;

name_position[j]++;

strcpy (list[i].Name, name_source[j]);

j=rand()%25;

while(acct_position[j]!= UNOCCUPIED)

j=rand()%25;

acct_position[j]++;

strcpy(list[i].account, acct_source[j]);

j=rand()%7;

strcpy(list[i].state , state[j]);

j=rand()%12;

strcpy(list[i].areaCode, area_code[j]);

j=rand()%25;

while(mobile_number_position[j]!= UNOCCUPIED)

j=rand()%25;

mobile_number_position[j]++;

strcpy(list[i].mobileNumber, mobile_number_source[j]);

j = rand() % 6;

list[i].lastmonthpayment = atof(lastmonth[j]);

j=rand()%12;

list[i].balance=atof(balance[j]);

}

return listsize;

}

void quit(char ** list, int K)

{

int i;

for(i=0; i

free(list[i]);

}

---------------------------------------------------------

lab10.h

#include

#include

#include

#ifndef _TEN_

#define _TEN_

struct cellData{

char Name[50];

char account[5];

char state[3];

char areaCode[4];

char mobileNumber[8];

double lastmonthpayment;

double balance;

};

#endif

int generate_Structlist(struct cellData* list, int K);

void Structquit(struct cellData* list, int listsize);

int generate_list(char ** list, int K);

void quit(char ** list, int listsize);

In this lab we will have 3 files, lab10.c, lab10 main.c and lab10.h. All your work wil be done in the lab10 main.c. You only need to write the functions that are called. All code will compile and run. The functions have been provided in lab10 main.c but they are empty. You don't need to modify lab10.h and lab10.c. These are used to create random lists for you to run your functions on The program consists of two array listl], this is an array of char pointers and STRListll this array is an array of struct cellData. You do not need to modify lab 10.h. You do not need to modify lab 10.c. Each char pointer is list points to a string of the form "Name Account Number STATE Area Code Mobile Number Last Months payment Balance" Example Brian King 2134 N 317 34111 22412.39*245.67" In this lab we will have 3 files, lab10.c, lab10 main.c and lab10.h. All your work wil be done in the lab10 main.c. You only need to write the functions that are called. All code will compile and run. The functions have been provided in lab10 main.c but they are empty. You don't need to modify lab10.h and lab10.c. These are used to create random lists for you to run your functions on The program consists of two array listl], this is an array of char pointers and STRListll this array is an array of struct cellData. You do not need to modify lab 10.h. You do not need to modify lab 10.c. Each char pointer is list points to a string of the form "Name Account Number STATE Area Code Mobile Number Last Months payment Balance" Example Brian King 2134 N 317 34111 22412.39*245.67

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!