/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Problem 10 Assume that \(r 1\) and \(r 2\) ... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

Assume that \(r 1\) and \(r 2\) are variables that reference Rectangle objects, and the following statements are executed: r1.setLength(5.0); r2.setLength(10.0); r1.setWidth(20.0); r2.setWidth(15.0);

Short Answer

Expert verified
Answer: - Rectangle 1 (r1): Area = 100.0 square units, Perimeter = 50.0 units - Rectangle 2 (r2): Area = 150.0 square units, Perimeter = 50.0 units

Step by step solution

01

Initialize the Rectangles' dimensions

Firstly, let's set the dimensions for both rectangles: - Rectangle 1 (r1): Length = 5.0 units, Width = 20.0 units - Rectangle 2 (r2): Length = 10.0 units, Width = 15.0 units
02

Calculate the area of each Rectangle

The area of a rectangle is given by the formula \(Area = Length \times Width\). Therefore, the areas of r1 and r2 are: - Area of r1 = Length of r1 * Width of r1 = 5.0 * 20.0 = 100.0 square units - Area of r2 = Length of r2 * Width of r2 = 10.0 * 15.0 = 150.0 square units
03

Calculate the perimeter of each Rectangle

The perimeter of a rectangle is given by the formula \(Perimeter = 2 \times (Length + Width)\). Therefore, the perimeters of r1 and r2 are: - Perimeter of r1 = 2 * (Length of r1 + Width of r1) = 2 * (5.0 + 20.0) = 2 * 25 = 50.0 units - Perimeter of r2 = 2 * (Length of r2 + Width of r2) = 2 * (10.0 + 15.0) = 2 * 25 = 50.0 units
04

Outputs

As per the above calculations, the areas and perimeters of the given Rectangle objects are: - Rectangle 1 (r1): Area = 100.0 square units, Perimeter = 50.0 units - Rectangle 2 (r2): Area = 150.0 square units, Perimeter = 50.0 units

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.