$30
CMPSC 221.1 – Object-Oriented Programming with Web Apps
Problem Set 4
The following problem set will be worth 100 points. The code will be submitted electronically via
Canvas using the “Problem Set 4” dropbox. The assignment is due at the start of the class two weeks
from the date it was assigned.
Your code will be graded on both elegance and user-friendliness.
Exercise #1 –Text Editor Problem (25pts)
Implement a Swing/JavaFX notepad application shown below:
Use JTextArea to hold the text. Include menu items which will save the text to the specified location,
a new option which will empty out the text field, an open option which can load text from another file
on the filesystem, and a close option which can close the application. (Use appropriate JavaFX
components if not using Swing.)
Last Modified: 10/24/2022
Exercise #2 – Calculator Problem (25pts)
Implement a Swing/JavaFX calculator. Model your application like the following:
Include basic functionality for each of the buttons shown above. Include one read-only text field to
show the results. Include a menu bar with options for “File” and “Help”. The “File” menu item should
have a menu item to close the window.
Last Modified: 10/24/2022
Exercise #3 – Bar Chart Problem (25pts)
Implement a Swing/JavaFX application which draws a vertical bar chart. The input is an array of
integers (you can hardcode the data in your application.) Use the index of an array entry as an entry on
the X axis. The height of the bar should correspond to the value of the array entry. For instance, if the
array entries are {3000, 4000, 5000}, then the bars should not be drawn 3000, 4000, and 5000 pixels
tall (respectively.) They should be drawn in the current proportion to the original values (perhaps 300,
400, and 500 pixels tall, but in the end it will depend on the size of your actual window.
As an example you can render your bar chart like the following (ignoring the tabs on top of the
window):
Last Modified: 10/24/2022
Exercise #4 – Triangle Problem (25pts)
A Sierpinski Triangle is a fractal with the overall shape of an equilateral triangle, divided recursively
into smaller equilateral triangles. As an example of the fractal:
As an example of the algorithm:
1. Start first with an equilateral triangle
2. Divide it into four smaller congruent equilateral triangles and remove the inner triangle
3. Repeat step 2 with each of the smaller triangles.
Last Modified: 10/24/2022
For this assignment you are to build a Swing/JavaFX application which can draw Sierpinski triangles.
Include a text box for the order which redraws the triangles whenever the value is changed.
As an example of the application:
Submission Requirements: Submit the aforementioned files in a zip file with the naming strategy:
First initial + last name + PS + problem set number.zip
As an example, I would submit the code in a zip file named mmeluskyPS4.zip. Submit your zip file
via the “Problem Set 4” Canvas dropbox before the date of the close of the assignment.