CS 341, Fall 2024                  Iyengar           Individual Programming Project # 2

                                    Due: Midnight Sunday 10/20/24

 

Creating Histogram

 

This assignment has the same objectives as assignment 1. But – the items are to be maintained in a linked multi-list. A multi-list is a list that appears to be multiple lists – depending on how you traverse as it has multiple next for every element in the list. Implement the insert into the list such that the element is sorted by a certain attribute. Additionally – implement insert into the list such that the element is sorted by a different attribute. Thus, depending on the traversal based on a certain attribute – the items will be visited in order of the attribute chosen.

 

There will be no need to sort when the histograms are to be displayed!

 

 

Input:

A text file named “Values.dat” with string with three values per line, up to 20 values in the file. The values represent – item_name, price, inventory, profitability, for items. Hence create an Item class and use an array of items to store the objects represented by each line.

 

Output:

A histogram displayed based on the selection made on the user interface – that enables a selection of price or inventory or profitability and ascending or descending. Thus, the user can view the items (names) from lowest price to highest price or vice-versa. Alternately – the user can view the items (names) from lowest inventory to highest inventory or vice-versa. Similarly, for profitability.

 

The user should be able to choose multiple options (and view the histograms) until – an exit option is chosen.

 

Questions and Collaboration:  Any questions about the problem – email, inquiry in class or discussion with instructor. You are free to discuss the problem-solving part. Do not view or use code developed by others.

 

Requirement:

You must implement your own data management and sorting routines (not use Java libraries). For display purposes you can use a simple horizontal histogram using normalized values using ‘*’s.

 

Assume all values to be integers – price range ($) 1 – 20; inventory range (#) – 100 – 1000; and profitability (%) – 10 – 50.

 

Your application must work for an unknown number of items in the input file (up to 100).

 

Example:

 

Input:              Apple              4 500 20

                        Orange            6 300 30

                        Banana            8 900 20

 

Output:

User selection – Price, Ascending

 

                        Items displayed by ascending order of price ($)

 

                        Apple              (4)       ****

                        Orange            (6)        ******

                        Banana            (8)        ********

                                               

 

            User selection – Profitability, Descending

 

                        Items displayed by descending order of profitability (%)

 

                        Orange            (30)      ***

                        Apple              (20)      **

                        Banana            (20)      **

 

           

            User selection – Inventory, Ascending

 

                        Items displayed by ascending order of inventory (#)

 

                        Orange            (300)    ***

                        Apple              (500)    ****

                        Banana            (900)    *********

 

            User selection: Exit

 

                        Thanks for using our handy-dandy item management system!

 

 

We will use aspects of this assignment in the next one – so you can plan your code accordingly for reuse.