1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alex41 [277]
3 years ago
12

For this exercise, you'll use the Rectangle class below (you can assume that the length and width are measured in feet).

Computers and Technology
1 answer:
dusya [7]3 years ago
8 0

Answer:

The solution code is written in Python:

  1. class Carpet:
  2.    def __init__(self, rect, cost):
  3.        self.size = rect  
  4.        self.costPerSqFoot = cost  
  5.    
  6.    def cost(self):
  7.        carpetCost = self.size.area() * self.costPerSqFoot  
  8.        return carpetCost

Explanation:

Presume that there is existence of Rectangle class as given in the question, Carpet class is written. The Carpet constructor is defined that take Rectangle object,<em> rect</em>, and <em>cost</em> as parameter (Line 2). To create data member of Carpet class, keyword "self" is used to precede with the name of the data members, <em>size </em>and <em>costPerSqFoot </em>(Line 3-4).<em> </em>The data members are initialized with the parameter <em>rect </em>and <em>cost</em>, respectively.

Next, cost method is defined (Line6 - 8). Within the <em>cost </em>method, the area method of Rectangle object is invoked by expression, <em>self.size.area() </em>and<em> </em>this will return the area value and multiplied with the costPerSqFoot to get the carpet cost and return it as output (Line 8).

You might be interested in
Write a filter that reads in a sequence of integers and prints the integers, removing repeated values that appear consecutively.
lara31 [8.8K]

Answer:

Following is the code for filter:

public class filter

{ public static void main(String[] args)

{ int x = StdIn.readInt();

System.out.print(" " + x + " ");

while(!StdIn.isEmpty())

{ int y = StdIn.readInt();

    if(y != x)

          System.out.print(" " + y + " ");

    x = y;

    }

    }

    }

Explanation:

  • A public class filter is used.
  • The main function will accept a single argument as string[], it is also known as java command line argument.
  • Now the Stdln.readInt is used to read the integers in the sequence and store it in integer x.
  • The value stored in variable x will be printed using System.out.print
  • Now unless the Stdln.readInt gets an empty value, check each value of sequence and store in variable y.
  • If y is not equal to previous value x, print it and shift the value of y into x.
  • Repeat the loop again.

i hope it will help you!

7 0
3 years ago
Read 2 more answers
Pleasee help meeeeeeeeee I’m stuckk!!!!
Anit [1.1K]

Answer: Charles Babbage

4 0
2 years ago
Read 2 more answers
Use System.DateTime along with System.Console to implement a simple C# program that does the following:_______.
Andre45 [30]

Answer:

5

Explanation:

I did it to and it was right

3 0
2 years ago
A customer in Lowe's needs help. Matt works in shipping and receiving. It isn't Matt job to work with the customer, but he knows
klio [65]

Answer:

40

Explanation:

hhhhhjjjj

5 0
2 years ago
Read 2 more answers
The equivalent of the TTL field in an ipv4 header is known as the ___an IPv6 header
OLga [1]
<span>The equivalent of the TTL(Time to Live) field in an IPv4 header is known as the Hop Limit in an IPv6 header.
</span>The IPv6 header is a streamlined version of the IPv4 header. The field Hop Limit has the size of 8 bits and indicates the maximum number of links over which the IPv6 packet can travel before being discarded.
7 0
3 years ago
Other questions:
  • What software is typically used for larger systems?
    11·1 answer
  • The cost of large ground based telescopes has remained the same since the 1800's costing the equivalent of about a billion dolla
    9·1 answer
  • You can use this effect to break a color into a percentage of its full strength.
    13·1 answer
  • a third important logical element is the inverter. an inverter does pretty much what it says. if the input is 0, the output is 1
    13·1 answer
  • Controlling access of information on the internet
    15·1 answer
  • Can change the tab colors of the worksheets in excel
    13·1 answer
  • What is the difference between MySQL and MariaDB?
    9·1 answer
  • Lesson 2.7 Code Practice #2
    13·1 answer
  • Please answer this simple (hard) question for me lol
    13·2 answers
  • Create a file using any word processing program or text editor. Write an application that displays the files, name, containing f
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!