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, 22.06.2019 17:00
The two main ways in which marketers address the competition with their strategies are by satisfying a need better than a competition and by
Answers: 2
question
Computers and Technology, 22.06.2019 17:30
The forerunner to cell phones, pdas, and smartphones was
Answers: 1
question
Computers and Technology, 23.06.2019 18:30
List 3 items that were on kens resume that should have been excluded
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
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
English, 24.08.2019 04:30
question
Mathematics, 24.08.2019 04:30
Questions on the website: 13722362