CMSC350 Project 3 - The third programming project

CMSC 350 Project 3 The third programming project involves writing a program that performs a sort by using a binary search tree. The program should be able to sort lists of integers or lists of fractions in either ascending or descending order. One set of radio buttons should be used to determine whether the lists contain integers or fractions and a second set should be used to specify the sort order. The main class should create the GUI shown below: The GUI must be generated by code that you write. You may not use a drag-and-drop GUI generator. Pressing the Perform Sort button should cause all the numbers in the original list to be added to a binary search tree. Then an inorder traversal of the tree should be performed to generate the list in sorted order and that list should then be displayed in the sorted list text field. In addition to the main class that defines the GUI, you should have a generic class for the binary search tree. That class needs a method to initialize the tree, one that allows a new value to be inserted in the tree and one that performs an inorder tree traversal that generates and returns a string that contains the tree elements in sorted order. The insert method does not need to rebalance the tree if it becomes unbalanced. It should allow duplicate entries and it must be written using recursion. It is not necessary to have a method to delete a node from the tree nor one to check whether a particular value is in the tree. The third class required for this project is one that defines fractions. It should have a constructor that accepts a string representation of a fraction and a toString method. It must implement theComparable interface, which means a compareTo method is also required. A second example of a run of this program is shown below that sorts fractions in descending order: Note that fractions are to be written with a slash separating the numerator and denominator with no spaces on either side of the slash. The only error checking required of this program is to check for nonnumeric input which includes improperly formatted fractions such as 3/4/8. Such malformed fractions should cause a NumberFormatExpression to be thrown. The main class must catch these exceptions and display an appropriate error message as shown below: You are to submit two files.

5,505views
4.3
(81 ratings)

Related Study Guides

Accounting Questions & Answers | Solutioninn.com

1. Tiana Morales is the director of the customer call center for Pierce Software. For the past three months, she has been keeping track of the support calls the center receives, and asks for your... B...

human-resourcesaccounting

IT3215 | Programming Methods in Computer Science - Capella university

4. Jen Stevens Hint: Use the splice function in order to remove a specific item from the array. Tip: The array index starts at 0, so when displaying the index, you will need to add 1 to the index valu...

information-systemshuman-resources

[Solved] MAG Petroleum is an SME specialising in t | SolutionInn

5. Recommend when the system that you have developed should be updated to account for new sales data that will occur. Assume you have a computer software package. Table 1: Lubricant Sales for MAG PETR...

computer-scienceeconomics

IT3215 | Programming Methods in Computer Science - Capella university

4. Jen Stevens Hint: Use the splice function in order to remove a specific item from the array. Tip: The array index starts at 0, so when displaying the index, you will need to add 1 to the index valu...

information-systemshuman-resources

Week 8 assignment: essay – interrelationships reflection apa format | Applied Sciences homework help

5. If possible, record the movement, but begin with the development section; then follow with the recapitulation, exposition, and coda sections. Does listening to this “reorganization’’ help clarify t...

communicationhuman-resources

Emppcase | Applied Sciences homework help

4. Some of SIA’s HR practices would be illegal in the U.S. Is this fair competition, or are those HR practices encouraging a “race to the bottom” in terms of employee rights? Bring in at least 5 libra...

economicshuman-resources

Discussion 1 and 2 | BUS 340 Business Communications | Ashford University - San Diego, CA

discussion 1 and 2 quonna31discussion 1 Prior to beginning work on this discussion, read Chapter 7, Chapter 8, and Chapter 12 from your textbook; the Week 3 Weekly Lecture, the article The Challenge o...

communicationhuman-resources

Ancient medieval art | Education homework help

4. What are the convergences between art and writing? First, define what you think the function of writing is. Then choose an object with images from this unit and discuss how it fulfills that functio...

art-designhuman-resources

Need Help With A Similar Question?

Our experts deliver perfect solutions with guaranteed A+ grades

A+
Student Grade
98%
Success Rate
12h
Delivery Time
Join 1,000+ students who got their perfect solutions
Rated 4.9/5 by satisfied students

Need Help With This Question?

Academic Expert

Subject Matter Specialist

98%
Success Rate
24/7
Support

Why Students Trust Us

  • PhD-Level Expertise
  • Original Work Guarantee
  • Better Grade or Free

"Got an A+ on my assignment. Exactly what I needed!"

Recent Student