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
vivado [14]
3 years ago
12

Consider the following implementation of a class Square:

Computers and Technology
1 answer:
DaniilM [7]3 years ago
4 0

Answer:

The answer to this question can be given as:

Code:

class Square   //define class Square

{

Private int sideLength;  //define variable  

Square(int length)   //define parameterized constructor.        

{

sideLength = length;        //hold value of the parameter

}

int getArea()                  //define function getArea.

{

Private int area;            //define variable.

area = sideLength * sideLength;          //calculate area.

return area;            //return value.

}

}

Explanation:

In this question it is not a good idea to introduce an instance variable for the area because It may be a different method that defines the same variable with the same name but different variables because they are related to different functions, so it is better to make this variable local in this case.

You might be interested in
your browsing the internet and realize your browser is not responding. which of the following will allow you to immediately exit
Mandarinka [93]

Answer:

Task Manager is the answer

8 0
3 years ago
Edhesive assignment 7 calendar
ikadub [295]

Answer:

def leap_year(y):

 if y % 4 == 0:

     return 1

 else:

     return 0

def number_of_days(m,y):

 if m == 2:

     return 28 + leap_year(y)

 elif m == 1 or m == 3 or m == 5 or m == 7 or m == 8 or m ==10 or m == 12:

     return 31

 elif m == 4 or m == 6 or m == 9 or m == 11:

     return 30

def days(m,d):

 if m == 1:

     return 0 + d

 if m == 2:

     return 31 + d

 if m == 3:

     return 59 + d

 if m == 4:

     return 90 + d

 if m == 5:

     return 120 + d

 if m == 6:

     return 151 + d

 if m == 7:

     return 181 + d

 if m == 8:

     return 212 + d

 if m == 9:

     return 243 + d

 if m == 10:

     return 273 + d

 if m == 11:

     return 304 + d

 if m == 12:

     return 334 + d

def days_left(d,m,y):

 if days(m,d) <= 60:

     return 365 - days(m,d) + leap_year(y)

 else:

     return 365 - days(m,d)

print("Please enter a date")

day=int(input("Day: "))

month=int(input("Month: "))

year=int(input("Year: "))

choice=int(input("Menu:\n1) Calculate the number of days in the given month.\n2) Calculate the number of days left in the given year.\n"))

if choice == 1:

 print(number_of_days(month, year))

if choice == 2:

 print(days_left(day,month,year))

Explanation:

Hoped this helped

5 0
2 years ago
5 minutes speech on computer and it's impact​
yuradex [85]

Answer:

used for inter eliptics

7 0
2 years ago
Read 2 more answers
Select the correct answer.
Anettt [7]

Answer:

D.extended-star topology

Explanation:

8 0
2 years ago
RedactedYou are a spy. The file attached has a series of messages that need to be encrypted before being sent. Open the file "me
Montano1993 [528]

Hey! How are you? My name is Maria, 19 years old. Yesterday broke up with a guy, looking for casual sex.

Write me here and I will give you my phone number - *pofsex.com*

My nickname - Lovely

7 0
2 years ago
Other questions:
  • How many homes can be warmed by one bugatti
    11·2 answers
  • What is the purpose of a scatter plot introduction to computer applications
    6·2 answers
  • Which is an example of an incremental approach to solving a problem?
    15·1 answer
  • Differences of a desktop computer and a laptop
    13·1 answer
  • fill in the balenkes ) 1)there are ................................... function keys on the keybord 2)pressing the end key moves
    6·1 answer
  • Please help explain this calculator code.
    15·1 answer
  • Why is it useful for students to practice the MLA and APA citation methods?
    15·1 answer
  • The company generates a lot of revenue and is rapidly growing. They're expecting to hire hundreds of new employees in the next y
    6·1 answer
  • You are considering using Wi-Fi triangulation to track the location of wireless devices within your organization. However, you h
    9·1 answer
  • A specialized output device for producing charts, maps, and very high-quality drawings is
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!