Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA rectanglefile.txt information: 10 15 @ ! 3 3 1 0 8 9 M m 20 20 ~ = 12 10 + + 4

IN JAVA

image text in transcribed

image text in transcribed

rectanglefile.txt information:

10 15 @ ! 3 3 1 0 8 9 M m 20 20 ~ = 12 10 + + 4 5 ( ) 7 10 $ 4 8 8 T " 1 9 y n 9 1 N Y

Example output:

Rectangle 0: Height = 10 Width = 15 Border = @ Fill = ! Area = 150 Perimeter = 50 Square? = no @@@@@@@@@@@@@@@ @!!!!!!!!!!!!!@ @!!!!!!!!!!!!!@ @!!!!!!!!!!!!!@ @!!!!!!!!!!!!!@ @!!!!!!!!!!!!!@ @!!!!!!!!!!!!!@ @!!!!!!!!!!!!!@ @!!!!!!!!!!!!!@ @@@@@@@@@@@@@@@ Rectangle 1: Height = 3 Width = 3 Border = 1 Fill = 0 Area = 9 Perimeter = 12 Square? = yes 111 101 111 Rectangle 2: Height = 8 Width = 9 Border = M Fill = m Area = 72 Perimeter = 34 Square? = no MMMMMMMMM MmmmmmmmM MmmmmmmmM MmmmmmmmM MmmmmmmmM MmmmmmmmM MmmmmmmmM MMMMMMMMM Rectangle 3: Height = 20 Width = 20 Border = ~ Fill = = Area = 400 Perimeter = 80 Square? = yes ~~~~~~~~~~~~~~~~~~~~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~~~~~~~~~~~~~~~~~~~~ Rectangle 4: Height = 12 Width = 10 Border = + Fill = + Area = 120 Perimeter = 44 Square? = no ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ ++++++++++ Which rectangle would you like to work on? (0 .. 4) :3 Height = 20 Width = 20 Border = ~ Fill = = Area = 400 Perimeter = 80 Square? = yes ~~~~~~~~~~~~~~~~~~~~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~==================~ ~~~~~~~~~~~~~~~~~~~~ Enter your choice: h) Change the height w) Change the width b) Change the border character f) Change the fill character r) Reset the rectangle to default values q) Quit : b Enter the new border character: 9 Height = 20 Width = 20 Border = 9 Fill = = Area = 400 Perimeter = 80 Square? = yes 99999999999999999999 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 9==================9 99999999999999999999 Enter your choice: h) Change the height w) Change the width b) Change the border character f) Change the fill character r) Reset the rectangle to default values q) Quit : w Enter a new width: 9 Height = 20 Width = 9 Border = 9 Fill = = Area = 180 Perimeter = 58 Square? = no 999999999 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 9=======9 999999999 Enter your choice: h) Change the height w) Change the width b) Change the border character f) Change the fill character r) Reset the rectangle to default values q) Quit : h Enter a new height: 4 Height = 4 Width = 9 Border = 9 Fill = = Area = 36 Perimeter = 26 Square? = no 999999999 9=======9 9=======9 999999999 Enter your choice: h) Change the height w) Change the width b) Change the border character f) Change the fill character r) Reset the rectangle to default values q) Quit : f Enter the new fill character: l Height = 4 Width = 9 Border = 9 Fill = l Area = 36 Perimeter = 26 Square? = no 999999999 9lllllll9 9lllllll9 999999999 Enter your choice: h) Change the height w) Change the width b) Change the border character f) Change the fill character r) Reset the rectangle to default values q) Quit : r Height = 5 Width = 5 Border = * Fill = # Area = 25 Perimeter = 20 Square? = yes ***** *###* *###* *###* ***** Enter your choice: h) Change the height w) Change the width b) Change the border character f) Change the fill character r) Reset the rectangle to default values q) Quit : f Enter the new fill character: h Height = 5 Width = 5 Border = * Fill = h Area = 25 Perimeter = 20 Square? = yes ***** *hhh* *hhh* *hhh* ***** Enter your choice: h) Change the height w) Change the width b) Change the border character f) Change the fill character r) Reset the rectangle to default values q) Quit : b Enter the new border character: w Height = 5 Width = 5 Border = w Fill = h Area = 25 Perimeter = 20 Square? = yes wwwww whhhw whhhw whhhw wwwww Enter your choice: h) Change the height w) Change the width b) Change the border character f) Change the fill character r) Reset the rectangle to default values q) Quit : q Goodbye.

I have finished this program but I would like to see another version of it. 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 Quit. What to turn in: Turn in any.java files you created to complete this assignment. Do NOT turn in anything else! No.class files. No sin files. Just.java files. Your program output does not have to be exactly like the example solution, but it must have all the things shown there and be neat

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions

Question

16. What makes them unique? (special features of the group)

Answered: 1 week ago