Soal Case her-shey bar her-shey bar is a famous chocolate shop in Indonesia that has order from every location worldwide
Posted: Sun Jul 03, 2022 9:59 am
Soal Case her-shey bar her-shey bar is a famous chocolate shop in Indonesia that has order from every location worldwide. In the past, manually tracking the data of each chocolate they produce is still manageable. Now, given tons of chocolate are being produced everyday, the CEO of her-shey bar, Mr. James hired you to create an application which uses AVL Tree as its base algorithm for fast data management. You are to create an application based on the following requirements: • At the start of the program, there will be 4 menus, which consists of: Add Chocolate View all Chocolate Remove Chocolate Exit . .
her-shey bar (_/\_)() 1. Add Chocolate 2. View all Chocolates 3. Remove Chocolate 4. Exit Choose >> Figure 1. main menu
If user choose menu 1 (Add Chocolate), the program will : Prompt user to input Chocolate Brand. Validate the input based on following conditions: > Input must be between 3 and 30 characters (inclusive) ➤ Input must be in capital format and consist of alphabets and spaces only Prompt user to input Chocolate Weight. Validate the input must be more than 20 and multiple of 5 Prompt user to input Chocolate Type. Validate the input must be between "White", "Milk", "Dark", "Cocoa", and "Ruby" (case sensitive) Prompt user to input Chocolate Price. Validate the input must be between 1.0 and 5000.0 (inclusive) Prompt user to input Confirmation Input. Validate the input must be between "Y" and "N" (case sensitive) If Confirmation Input is "Y", > Generate Chocolate ID based on following formula: . . . . . . XXX-YY-ZZZZ XXX: First 3 characters of Chocolate Type in uppercase YY: First 2 characters of Chocolate Brand in uppercase ZZZZ: Last Chocolate ID count incremented by 1 ➤ Finally, create a node with all data and push unto AVL Tree with Chocolate ID as its key
Input chocolate brand [3 - 30 characters]: da Input chocolate brand [3] 30 characters]: Dairy Queen Input chocolate weight [> 20, multiple of 5]: 15 Input chocolate weight [> 20, multiple of 5]: 35 Input chocolate type [White | Milk | Dark | Cocoa | Ruby]: milk Input chocolate type [White | Milk | Dark | Cocoa | Ruby]: Cocoa Input chocolate price [$1.0 - $5000.0]: 0 Input chocolate price [$1.0 - $5000.0]: 4.9 Are you sure want to add? [Y | N]: y Are you sure want to add? [Y | N]: Y Chocolate with ID COC-DA-0004 added succesfully

ID | Brand | Reese's | Snickers | Dairy Queen MIL-RE-0003 DAR-SN-0002 COC-DA-0004 WHI-KI-0001 | Kit Kat Press enter to continue... ID | Brand COC-DA-0004 | Dairy Queen DAR-SN-0002 | Snickers MIL-RE-0003 | Reese's WHI-KI-0001 | Kit Kat Figure 5. view data in pre-order format If View Input is "In", display all data in in-order format Press enter to continue... | Weight | Type | 135 g | Milk | 200 g| Dark | 35 | 25 | Price | $11.5 | $9.9 g Cocoa | $4.9 g | White | $5.4 | Weight | Type | Price | 35 g Cocoa | $4.9 | 200 g | Dark | $9.9 | $11.5 | $5.4 | 135 | 25 g Milk g White I Figure 6. view data in in-order format ➤ If View Input is "Post", display all data in post-order format
Input ID to remove [0 to return to main menu]: A Input ID to remove [0 to return to main menu]: Figure 10. searched data not exists Otherwise, ❖ Prompt user to input Confirmation Input. Validate the input must be between "Y" and "N" (case sensitive) Input ID to remove [0 to return to main menu]: MIL-RE-0003 Are you sure want to remove chocolate MIL-RE-0003? [Y | N]: Figure 11. confirmation input prompt If Confirmation Input is "Y", remove data from AVL Tree and display following message Input ID to remove [0 to return to main menu]: MIL-RE-0003 Are you sure want to remove chocolate MIL-RE-0003? [Y | N]: Y Chocolate with ID MIL-RE-0003 removed! Press enter to continue... Figure 12. successfully delete data message Otherwise, redirect to main menu If user choose menu 4 (Exit), the program will close