I\'m really confused on this C programming lab. I had been been spending over we
ID: 3691517 • Letter: I
Question
I'm really confused on this C programming lab. I had been been spending over week on this lab, but still confused. It keeps showing error when I ran my programming. I'll be really thankful if someone could help me.
You need to download the following
Lab11.c,
Lab11_main.c
Lab11.h.
In this lab we will have 3 files- Lab11.c, Lab11_main.c and Lab11.h. All your work will be done in the Lab11_main.c, you don't need to modify Lab11.h and Lab11.c.
We will be using the structure:
struct CustomerData{
char name[30];
int ID;
float monthlybill;
double yearlybill
struct CustomerData * nextCustomer;
};
In your main write a series of statements that ask the user to input a positive integer NUM. Then generate a link list of NUM nodes (one node at a time). Use void assigndata (struct CustomerData *V) to generate data for each node in the link list. This function is already written for you in Lab11.c. You need to call it from your main. Add new nodes in your link list so that the list maintains a non-decreasing order of the monthlybill field of struct CustomerData.
Then write a function that is passed this link list and returns the average yearlybill of all the link list elements. You should call this function in main and output the result in a formatted manner in main.
Lab11_main.c
#include "Lab11.h"
int main(void)
{
}
Lab11.c
#define _CRT_SECURE_NO_WARNINGS
#include "Lab11.h"
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"};
void assigndata(struct CustomerData *V)
{
static int done=0;
int seed =8192;
int numStrings;
if(!done)
{
done =1;
srand(seed);
}
numStrings=sizeof(name_source)/sizeof(char *);
V->ID=rand()%215;
V->monthlybill= (float)(rand()%1000);
V->yearlybill=(double) (rand()%10000);
strcpy(V->name, name_source[rand()%numStrings]);
V->nextCustomer=NULL;
}
Lab11.h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifndef __LAB_11__
#define __LAB_11__
struct CustomerData{
char name[30];
int ID;
float monthlybill;
double yearlybill;
struct CustomerData * nextCustomer;
};
#endif
void assigndata (struct CustomerData *V);