Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C! STARTER CODE INCLUDED! If you help I will appreciate so much. Very important. You work for a boat company. They need a program

IN C! STARTER CODE INCLUDED!

If you help I will appreciate so much. Very important.

You work for a boat company. They need a program that keeps track of inventory information. Please write a multi-file program to create a singly linked-list of watercraft. This will be based on structures - one for watercraft, one for accessories, and one for list, as given in a provided header file.

DIRECTIONS:

image text in transcribedFUNCTION PROTOTYPES:

image text in transcribed

image text in transcribed

image text in transcribed

STARTER CODE: sll_list.h

image text in transcribed

image text in transcribed

STARTER CODE: watercraft.txt

pontoon, Crest, Carribean RS 230 SLC, 1, Suzuki, 115, Blue, 26,134595.00,135945.00,1,200,0,250,450,450,0

fishing,Key West,239 FS,1,Mercury,250,Orange,24,86430.00,87630.00,0,0,250,200,500,250,0

sport boat,Tahoe,T16,1,Yamaha,300,Yellow,22,26895.00,27745.00,0,250,0,0,350,250,0

pontoon,Bennington,24 Slx,1,Mercury,140,Brown,24,83299.00,84049.00,1,250,0,200,0,300,0

kayak,Wilderness Systems,Tarpon 120 SOT,0,None,0,Red/Orange/Yellow,12,999.00,1149.00,0,0,0,0,0,0,150

pontoon,Suntracker,Bass Buggy 16 XL,1,Suzuki,115,Silver,22,13990.00,14990.00,1,200,0,250,300,250,0

pontoon,Crest,Classic LX 220 SLC,1,Mercury,115,Green,24,45599.00,47149.00,1,250,350,200,450,300,0

fishing,Phoenix,Bass Boat 920 Elite,2,Chevrolet,300,Orange,28,46995.00,48195.00,0,0,250,300,400,250,0

kayak,Eddyline,Rio,0,None,0,Green Apple,12,1429.00,1714.00,0,0,0,0,0,0,285

canoe,Old Town,Penobscot 164 ,0,None,0,Green,16,1299.95,1524.90,0,0,0,0,0,0,224.95

canoe,Mad River,Adventure 16,0,None,0,Red,16,899.00,1058.95,0,0,0,0,0,0,159.95

pontoon,Crest,Classic LX 200 L,1,Yamaha,150,Black,22,31816.00,33016.00,1,200,0,250,450,300,0

sport boat,Chaparral,297 Surf SSX,2,Chevrolet,300,Purple,24,220079.00,221279.00,0,250,350,0,400,200,0

fishing,Avenger,AV24,1,Yamaha,115,Gray,28,89995.00,90795.00,0,0,250,0,350,200,0

sport boat,Sea Ray,SDX 270,2,Chevrolet,300,Blue,28,185113.00,186213.00,0,200,300,0,350,250,0

fishing,Nitro,Z18 Pro,1,Suzuki,140,Black,30,35585.00,36235.00,0,0,0,0,400,250,0

pontoon,Bennington,25 Qxfb,1,Mercury,115,White,22,167000.00,168250.00,1,250,0,250,450,300,0

pontoon,Bentley,200 Cruise,1,Mercury,90,Silver,20,36995.00,37795.00,1,200,350,250,0,0,0

Menu should look like this:

image text in transcribed

Your program should contain the following files: 1. mainDriver.c (contains main() function) 2. sll_list.h (header file for this singly linked-list program provided to you) 3. sll_list.c implementation file for this doubly linked-list program) 4. watercraft.txt (contains watercraft for initializing your linked-list). The watercraft can be any kind of watercraft, such as pontoon, fishing, sport boat, sailboat, kayak, canoe, even ski jets (although there are no jet skis in the test file). You can add whatever types of watercraft that you want to the test file. Make sure that no fields are skipped, though. 5. makefile (Your makefile should have at least two targets: a compile target, which renames your executable to sll; and a clean target which removes the executable and any other un-needed files, like .o files if there are any) FUNCTION PROTOTYPES Initializing The List: int printMenu(); // prints the menu to the user; returns the menu choice list t *newList(); // creates a new list; initializes size, and head & tail pointers; returns a pointer to the new list void listInit( list_t *list, FILE *inFile ); // called from initializeFromFile(); call newWatercraft () to create and 17 initialize a new watercraft from the file; then add it to the end of // the list; increments the list size for each watercraft added void initialize FromFile( list t *list, FILE *inFile ); // calls listInit() sending the input file pointer (which is the file // specified at the command-line that was opened in the main() function) watercraft t *new waterCraft( FILE *in File); // called by listInit() function // creates and initializes a new watercraft node from the input file pointer sent in // returns a pointer to the watercraft that was just created Adding Additional Watercraft: void addToFront ( list_t *list ); // creates a new watercraft from user input and then adds it to the front of the list // increments the list size void addToRear( list_t *list ); // creates a new watercraft from user input and then adds it to the rear of the list; should use the tail pointer // increments the list size Printing Entire List Of All Watercraft Or Specs Of Chosen Watercraft: void printList ( list_t *list ); // prints all the watercraft in the list void printSpecs ( list_t *list ); // prints a list of the watercraf (i.e.calls printListo) and asks user to choose which one to show the specs of // the specs will include the extra items and their associated costs, if applicable Deleting A Watercraft: void deleteWatercraft( list_t *list ); // prints the list of watercraft (i.e.calls printList() and lets the user choose which one to delete // then deletes the chosen watercraft from the list // decrements the list size // if list is empty, prints message that the list is empty Searching For And Printing Watercraft By Type Or Motor: int typeInInventory ( list_t *list, char whichOne [] ); // called by searchByType() function // search the list and return a 1 if that type is found, 0 if not found int motor InInventory ( list_t *list, int whichone); // called by searchByMotorType() function // search the list and return a 1 if that motor type is found, 0 if not found (0 for no motor, 1 for out-board motor, and 2 for in-board) void printWatrcraftByType( list_t *list, char whichone'] ); 1/ traverses the list for the type that matches whichone and prints all found void printWatrcraftByMotor( list_t *list, int whichOne ); // traverses the list for propulsion that matches whichone and returns all found void searchByType( list_t *list ); // prints choices of types for user to choose the desired one (e.g. 1 for pontoon, 2 for fishing, etc.) // uses if-else statement or switch statement to call typeInInventory() sending the list and the string for the type chosen (e.g. "pontoon" or "fishing", etc.) // if typeIn Inventory () returns a 1, call printWatercraftByType() void searchByMotorType( list_t *list ); // prints motor types for user to choose the desired one (e.g. 1 for no motor, 2 for out-board motor, 3 for in-board motor) // uses if-else statement or switch statement to call motorInInventory) sending the list and the integer for the type chosen (0, 1, or 2) // if type In Inventory () returns a 1, call printWatercraftByMotor Type() Printing Watercraft By Price In Order From Lowest To Highest: void printByPrice ( list_t *list ); // creates a new local list built from the existing list where each watercraft is added in order from lowest to highest // once the new list of watercraft in order of price from lowest to highest is built, then call printList() to print the sorted list Utility Function That Can Be Used In Your Other Functions: int isEmpty( list_t *list ); // returns 1 if the list is empty and 0 if it is not empty Print Total Asset Value Of All Watercraft: void TAV( list_t *list ); 1/ prints the total asset value of all inventory (sum of total_price) 2. 1 #ifndef SLL_LIST_H #define SLL_LIST_H 3 4 #include #include #include 7 5 6 8 9 10 // cost of the add-on 12 13 typedef struct { double bimini; double towbar; double stereo; double table; double gps; double anchor; double paddles; } accessories_t; 14 15 16 17 19 20 21 22 23 24 25 26 27 28 29 30 typedef struct watercraft { char type [15]; // e.g. pontoon, sport boat, sailboat, fishing, canoe, kayak, jetski, etc, char make[20]; char model [30]; int propulsion; //= none; l = outBoard; 2 = inBoard; char engine[15]; // Suzuki, Yamaha, etc. int hp; // horse power char color [25]; int length; // feet double base_price; double total_price; accessories t extras; struct watercraft *next; } watercraft_t; 31 32 33 34 35 36 37 38 39 40 41 typedef struct list { watercraft_t *head; watercraft_t *tail; int size; } list_t; 43 44 45 46 47 48 49 int printMenu(); list_t *newList(); void listInit( list_t *list, FILE *infile); void initializeFromFile( list_t *list, FILE *inFile ); watercraft_t *new_waterCraft( FILE *inFile ); void addToFront ( list_t *list ); void addToRear( list_t *list ); 50 51 52 53 void printList ( list_t *list ); void printSpecs ( list_t *list ); 54 void deleteWatercraft( list_t *list ); 55 56 57 58 int typeInInventory( list_t *list, char whichone[]); int motorInInventory( list_t *list, int whichOne ); void printWatercraftByType( list_t *list, char whichone[]); void printwatercraftByMotor( list_t *list, int whichone ); void searchByType( list_t *list ); // pontoon, fishing boat, etc. void searchByMotorType( list_t *list ); // e.g. inboard vs outboard void printByPrice list_t *list ); // list from lowest to highest 59 60 61 62 63 64 65 66 67 68 69 70 71 72 int isEmpty( list_t *list ); void TAV( list_t *list ); // Total Asset Value #endif /* SLL_LIST_H */ 1. load inventory of watercraft from file 2. add additional watercraft to front of list 3. add additional watercraft to end of list 4. number of watercraft in inventory 5. print inventory of watercraft 6. print specs of chosen watercraft 7. delete chosen watercraft 8. search watercraft by type 9. search watercraft by motor type 10. sort watercraft by price 11. total asset value in inventory 12. quit program Your program should contain the following files: 1. mainDriver.c (contains main() function) 2. sll_list.h (header file for this singly linked-list program provided to you) 3. sll_list.c implementation file for this doubly linked-list program) 4. watercraft.txt (contains watercraft for initializing your linked-list). The watercraft can be any kind of watercraft, such as pontoon, fishing, sport boat, sailboat, kayak, canoe, even ski jets (although there are no jet skis in the test file). You can add whatever types of watercraft that you want to the test file. Make sure that no fields are skipped, though. 5. makefile (Your makefile should have at least two targets: a compile target, which renames your executable to sll; and a clean target which removes the executable and any other un-needed files, like .o files if there are any) FUNCTION PROTOTYPES Initializing The List: int printMenu(); // prints the menu to the user; returns the menu choice list t *newList(); // creates a new list; initializes size, and head & tail pointers; returns a pointer to the new list void listInit( list_t *list, FILE *inFile ); // called from initializeFromFile(); call newWatercraft () to create and 17 initialize a new watercraft from the file; then add it to the end of // the list; increments the list size for each watercraft added void initialize FromFile( list t *list, FILE *inFile ); // calls listInit() sending the input file pointer (which is the file // specified at the command-line that was opened in the main() function) watercraft t *new waterCraft( FILE *in File); // called by listInit() function // creates and initializes a new watercraft node from the input file pointer sent in // returns a pointer to the watercraft that was just created Adding Additional Watercraft: void addToFront ( list_t *list ); // creates a new watercraft from user input and then adds it to the front of the list // increments the list size void addToRear( list_t *list ); // creates a new watercraft from user input and then adds it to the rear of the list; should use the tail pointer // increments the list size Printing Entire List Of All Watercraft Or Specs Of Chosen Watercraft: void printList ( list_t *list ); // prints all the watercraft in the list void printSpecs ( list_t *list ); // prints a list of the watercraf (i.e.calls printListo) and asks user to choose which one to show the specs of // the specs will include the extra items and their associated costs, if applicable Deleting A Watercraft: void deleteWatercraft( list_t *list ); // prints the list of watercraft (i.e.calls printList() and lets the user choose which one to delete // then deletes the chosen watercraft from the list // decrements the list size // if list is empty, prints message that the list is empty Searching For And Printing Watercraft By Type Or Motor: int typeInInventory ( list_t *list, char whichOne [] ); // called by searchByType() function // search the list and return a 1 if that type is found, 0 if not found int motor InInventory ( list_t *list, int whichone); // called by searchByMotorType() function // search the list and return a 1 if that motor type is found, 0 if not found (0 for no motor, 1 for out-board motor, and 2 for in-board) void printWatrcraftByType( list_t *list, char whichone'] ); 1/ traverses the list for the type that matches whichone and prints all found void printWatrcraftByMotor( list_t *list, int whichOne ); // traverses the list for propulsion that matches whichone and returns all found void searchByType( list_t *list ); // prints choices of types for user to choose the desired one (e.g. 1 for pontoon, 2 for fishing, etc.) // uses if-else statement or switch statement to call typeInInventory() sending the list and the string for the type chosen (e.g. "pontoon" or "fishing", etc.) // if typeIn Inventory () returns a 1, call printWatercraftByType() void searchByMotorType( list_t *list ); // prints motor types for user to choose the desired one (e.g. 1 for no motor, 2 for out-board motor, 3 for in-board motor) // uses if-else statement or switch statement to call motorInInventory) sending the list and the integer for the type chosen (0, 1, or 2) // if type In Inventory () returns a 1, call printWatercraftByMotor Type() Printing Watercraft By Price In Order From Lowest To Highest: void printByPrice ( list_t *list ); // creates a new local list built from the existing list where each watercraft is added in order from lowest to highest // once the new list of watercraft in order of price from lowest to highest is built, then call printList() to print the sorted list Utility Function That Can Be Used In Your Other Functions: int isEmpty( list_t *list ); // returns 1 if the list is empty and 0 if it is not empty Print Total Asset Value Of All Watercraft: void TAV( list_t *list ); 1/ prints the total asset value of all inventory (sum of total_price) 2. 1 #ifndef SLL_LIST_H #define SLL_LIST_H 3 4 #include #include #include 7 5 6 8 9 10 // cost of the add-on 12 13 typedef struct { double bimini; double towbar; double stereo; double table; double gps; double anchor; double paddles; } accessories_t; 14 15 16 17 19 20 21 22 23 24 25 26 27 28 29 30 typedef struct watercraft { char type [15]; // e.g. pontoon, sport boat, sailboat, fishing, canoe, kayak, jetski, etc, char make[20]; char model [30]; int propulsion; //= none; l = outBoard; 2 = inBoard; char engine[15]; // Suzuki, Yamaha, etc. int hp; // horse power char color [25]; int length; // feet double base_price; double total_price; accessories t extras; struct watercraft *next; } watercraft_t; 31 32 33 34 35 36 37 38 39 40 41 typedef struct list { watercraft_t *head; watercraft_t *tail; int size; } list_t; 43 44 45 46 47 48 49 int printMenu(); list_t *newList(); void listInit( list_t *list, FILE *infile); void initializeFromFile( list_t *list, FILE *inFile ); watercraft_t *new_waterCraft( FILE *inFile ); void addToFront ( list_t *list ); void addToRear( list_t *list ); 50 51 52 53 void printList ( list_t *list ); void printSpecs ( list_t *list ); 54 void deleteWatercraft( list_t *list ); 55 56 57 58 int typeInInventory( list_t *list, char whichone[]); int motorInInventory( list_t *list, int whichOne ); void printWatercraftByType( list_t *list, char whichone[]); void printwatercraftByMotor( list_t *list, int whichone ); void searchByType( list_t *list ); // pontoon, fishing boat, etc. void searchByMotorType( list_t *list ); // e.g. inboard vs outboard void printByPrice list_t *list ); // list from lowest to highest 59 60 61 62 63 64 65 66 67 68 69 70 71 72 int isEmpty( list_t *list ); void TAV( list_t *list ); // Total Asset Value #endif /* SLL_LIST_H */ 1. load inventory of watercraft from file 2. add additional watercraft to front of list 3. add additional watercraft to end of list 4. number of watercraft in inventory 5. print inventory of watercraft 6. print specs of chosen watercraft 7. delete chosen watercraft 8. search watercraft by type 9. search watercraft by motor type 10. sort watercraft by price 11. total asset value in inventory 12. quit program

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Internals A Deep Dive Into How Distributed Data Systems Work

Authors: Alex Petrov

1st Edition

1492040347, 978-1492040347

More Books

Students also viewed these Databases questions