Question

Create class Rectangle. The class has attributes length and width, each of which defaults to 0.0. It has properties for both length and width. The set accessors should verify that length and width are each floating-point numbers greater than 0.0 and less than 20.0. It has read-only properties that calculate the Perimeter and the Area of the rectangle. Write an app to test class Rectangle.

          Create class Rectangle. The class has attributes length and width, each of which defaults to 0.0. It has properties for both length and width. The set accessors should verify that length and width are each floating-point numbers greater than 0.0 and less than 20.0. It has read-only properties that calculate the Perimeter and the Area of the rectangle. Write an app to test class Rectangle.
        
Show more…

Added by Jill F.

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
Create class Rectangle. The class has attributes length and width, each of which defaults to 0.0. It has properties for both length and width. The set accessors should verify that length and width are each floating-point numbers greater than 0.0 and less than 20.0. It has read-only properties that calculate the Perimeter and the Area of the rectangle. Write an app to test class Rectangle.
Close icon
Play audio
Feedback
Powered by NumerAI
Jennifer Stoner Danielle Fairburn
Ivan Kochetkov verified

Morgan Cheatham and 55 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
geometry-two-rectangles-write-a-program-that-prompts-the-user-to-enter-the-center-x-y-coordinates--2

(Geometry: two rectangles) Write a program that prompts the user to enter the center $x=, y$ -coordinates, width, and height of two rectangles and determines whether the second rectangle is inside the first or overlaps with the first, as shown in Figure $4.10 .$ Test your program to cover all cases.

Introduction to Programming Using Python

geometry-point-in-a-rectangle-write-a-program-that-prompts-the-user-to-enter-a-point-x-y-and-check-2

(Geometry: point in a rectangle?) Write a program that prompts the user to enter a point $(x, y)$ and checks whether the point is within the rectangle centered at (0,0) with width 10 and height $5 .$ For example, (2,2) is inside the rectangle and (6,4) is outside the rectangle, as shown in Figure $4.8 b$. (Hint: A point is in the rectangle if its horizontal distance to (0,0) is less than or equal to $10 / 2$ and its vertical distance to (0,0) is less than or equal to $5.0 / 2 .$ Test your program to cover all cases.) Here are two sample runs:

Introduction to Programming Using Python

write-a-program-java-language-that-computes-the-area-and-the-perimeter-of-a-rectangle-75845

Write a program (Java language) that computes the area and the perimeter of a rectangle.

Sarvesh S.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,570 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,141 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,512 solutions

*

Transcript

-
00:01 Hello, for problem 28, you're being asked to write a program that will take the x and y coordinates, as well as the width and height of two rectangles from a user and determine whether or not the second rectangle is inside the first or overlaps with the first.
00:22 And we want to, of course, test this program for lots of different cases.
00:27 So we will get the x, y, width, and height for triangle one and triangle two from the user, where we ask them to enter r1's center xy coordinates with and height, and the same for r2.
00:43 And then we need to check what's going on here.
00:48 So first, we're going to check if r1 is inside r2.
00:52 Then we'll check if r2 is inside r1.
00:55 I chose to do it this way.
00:58 It seems like in the question, it just wants you to determine whether the second rectangle is inside the first.
01:06 But i thought that it would be useful to know whether or not the first rectangle is inside the second.
01:11 And then we want to check if they overlap.
01:15 So how do we know if r1 is inside r2? well, if we start at the center of r1 and move out.
01:25 Out its width if that value is less than starting at the center of r2 and moving out its width.
01:34 And in the opposite direction, we have the same.
01:39 And in the y direction, that's true...
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Join the community

18,000,000+

Students on Numerade


Trusted by students at 8,000+ universities

Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever