Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab 10-1: Creating a Programmer-Defined Class in Java In this lab, you will create a programmer-defined class and then use it in a Java program.

image text in transcribed
Lab 10-1: Creating a Programmer-Defined Class in Java In this lab, you will create a programmer-defined class and then use it in a Java program. The program should create two Rectangle objects and find their area and perimeter. U the Circle class that you worked with in Exercise 10-1 as a guide. 1. Open the class file named Rectangle. java using Notepad or the text editor of 2. In the Rectangle class, create two private attributes named 1ength and width. Both length and width should be data type double. 3. Write public set methods to set the values for 1ength and width 4. Write public get methods to retrieve the values for length and width. 5. Write apublic calculateAreaO method and a public calculatePerimeterO method to calculate and return the area of the rectangle and the perimeter of the rectangle Save this class file, Rectangle.java, in a directory of your choice, and then open the file named MyRectangleClassProgram.java. In the MyRectangleClassProgram class, create two Rectangle objects named rectanglel and rectangle2 using the default constructor as you saw in EmployeeWages.java. 6. 7. Set the length of rectangle1 to 10.0 and the width to 5.0. Set the length of rectangle2 to 7.0 and the width to 3.0. Print the value of rectanglel's perimeter and area, and then print the value of rectangle2's perimeter and area. 8. 9. 10. Save MyRectangleClassProgram.java in the same directory as Rectangle.java. 11. Compile the source code file MyRectangleclassProgram.java. 12. Execute the program. 13. Record the output below

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago