1. Engineering
  2. Computer Science
  3. c the leader of a scout troop has a program...

Question: c the leader of a scout troop has a program...

Question details

C++

The leader of a scout troop has a program that members use to manage cookie sales. Members enter their orders into the program and it generates a file listing each customer’s name, the number of cookie types ordered, then for each type ordered, the number of boxes and cookie name. The first two records of a sample file are shown below:

Allia Ramez

2

1 Thin Mint

2 Carmel Delite

Samuel Hardash

3

2 Shortbread

1 Lemonade

2 Carmel Delite

Write a program that will process this file, reading the file name from the user, and then creating a linked list with records containing the following information, ordered alphabetically by cookie name.

struct CookieNode
{
     char cookie_name[COOKIE_NAME_SIZE];

     int num_boxes;

     char customer_name[CUSTOMER_NAME_SIZE];

     CookieNode * next;

};

After processing the file, your program should display a menu that allows the user to choose one of the following options:

  1. Print Ordering Summary
  2. Print List
  3. Exit

Each option is explained below:

  1. Print Ordering Summary: Displays a table. Each line contains a cookie name followed by a single number stating the total number of boxes of that cookie type that must be ordered to fill all orders in the list. The cookie names must appear in alphabetical order.
  2. Print List: Displays the linked list as a table with the data for each node on a separate line. Give the cookie name, number of boxes, and customer name for each node.
  3. Exit: Exits the program

Your program must continue to display the menu and process selections as stated above until the user chooses to exit the program.

Write a class named CookieList that contains a linked list of the CookieNode structures given above. Your class should include a constructor and destructor along with methods to insert a node and display the list.

Write a class named CookieFile that contains methods to read the file, print the ordering summary, and print the list. This class will include a CookieList member variable. The methods in this class will invoke the operations in the CookieList class as necessary.

Store your class declarations and member functions in separate files named with the class name and the appropriate extension (.h or .cpp).

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution