subject

For this lab you will write a class to create a user-defined type called Shapes to represent different shapes, their perimeters and their areas. The class should have three fields: shape, which is of type string, and perimeter and area of type double. The program will have to be able to calculate perimeters and areas for circles, triangles, squares and rectangles, which are the known shapes. 2.1 Constructors
Write these constructors:
1. Default constructor that sets the shape to "unknown" and the perimeter and area to 0
2. Constructor with one parameter, shape, that sets the shape, other fields are 0
2.2 Accessors & Mutators
Write the following member methods:
1. setShape()
Modifies the shape field
2. getShape()
Returns the shape field
3. getPerimeter()
Returns the perimeter field
4. getArea()
Returns the area field
Arithmetic Methods in Interface
Write the following member methods to perform arithmetic:
1. setPerimeter(Scanner scnr)
Depending on the shape, prompts the user for appropriate variables (ie width & height for a square, radius for a circle, etc.) and calculates the perimeter of the appropriate shape. The perimeter field should be updates with the new value. If the shape is unknown, then print to the screen that the user must first define a shape before a perimeter can be calculated and set the perimeter to 0.
2. setArea(Scanner scnr)
Depending on the shape, prompts the user for appropriate variables (ie width & height for a square, radius for a circle, etc.) and calculates the area of the appropriate shape. The area field should be updates with the new value. If the shape is unknown, then print to the screen that the user must first define a shape before an area can be calculated and set the area to 0.
2.3 Additional Methods
Create two additional methods of your choice. Be sure to clearly label both of these methods as your own.
2.4 Using another .java file called ShapesTest. java that tests that all of your methods work correctly

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 02:00
Which demographic challenge is europe currently experiencing? a. an aging and decreasing population b. a baby boomc. an unequal distribution between males and females d. a large group of teenagers moving through the school system(i chose a but i'm unsure)
Answers: 1
question
Computers and Technology, 23.06.2019 07:00
To produce a starlight effect in her photograph, lina should choose the filter for her camera.
Answers: 1
question
Computers and Technology, 24.06.2019 23:00
Hypertension occurs when blood pressure is too high.
Answers: 1
question
Computers and Technology, 25.06.2019 03:00
1. how do you view the edited document without the track changes markup? a. select accept all changes in document in the accept drop-down menu.b. click on restrict editing in the protect group.c. click on the reviewing pane drop-down menu in the tracking group.d. click on final in the display for review drop-down menu.
Answers: 3
You know the right answer?
For this lab you will write a class to create a user-defined type called Shapes to represent differe...
Questions
question
Mathematics, 11.12.2019 07:31
question
Social Studies, 11.12.2019 07:31
Questions on the website: 13722363