Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN JAVA I have this program completed I just want to see a possible different way to have it completed. Thanks! You are to write
IN JAVA
I have this program completed I just want to see a possible different way to have it completed. Thanks!
You are to write a program that displays a list of rectangles then allows the user to choose one of them and then lets the user do stuff with the rectangle they chose. The list of rectangles must be created by reading data from a file called "rectanglefile.txt". There will be data for at least 5 rectangles in the file. Each rectangle has four features: height, width, border character, and fill character. The height and width must always be positive integers. The border and fill characters are the characters that show up when you display the rectangle. The border character should be shown around the edges of the rectangle, while the fill character must be shown in the non-edge area of the rectangle. These characters must always be non-whitespace. If the rectangle is too short and/or narrow to show fill characters, only show border characters. So a rectangle with these stats: Height = 5 Width = 5 Border Character = '*' Fill Character = '# Would look like this: Your program must load 5 rectangles from an input file called "rectanglefile.txt". This file is guaranteed to hold valid data for at least 5 rectangles. A rectangle is stored as 4 values: height, width, border character, and fill character in that order. The file may have more than 5 rectangles in it. Stop reading when you've loaded the first 5. Once the rectangle data has been loaded, display a list of the details of the 5 rectangles. See the example output posted on moodle to see what needs to be shown. Show all the things displayed in the example output. Once the rectangles have been shown, ask the user to choose one of them. Error trap for out-of-range choices. Once a rectangle has been chosen, display it and let the user choose to do one of the following things to the rectangle: Change the height. Change the width. Change the border character. Change the fill character. Reset the rectangle to default values (see below). Quit. Accept the user's choice (with error trapping for bad selections), do the thing they chose, and, if it isn't Quit, repeat displaying the rectangle's details and letting the user choose from the list of things to do. If the user chooses to alter the height or the width, ask them for a new height or width (with error trapping for non-positive numbers) and apply that new value to the rectangle. If the user chooses to change one of the characters, accept the new character from the user. I recommend using Strings for this because they are easier to deal with. You can assume that the user will type a non-whitespace, single character when asked for these. If the user chooses to reset the rectangle to default values, set the rectangle to the following: 5,5, *, and #. End the program if the user chooses QuitStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started