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
laiz [17]
3 years ago
8

1. Write a toString method for this class. The method should return a string containing the radius and area of the circle.

Computers and Technology
1 answer:
Lady bird [3.3K]3 years ago
6 0

Answer:

public class Circle {

private double radius;

public Circle(double r)

{

radius = r;

}

public double getArea()

{

return Math.PI * radius * radius;

}

public double getRadius()

{

return radius;

}

public String toString()

{

String str;

str = "Radius: " + radius +

"Area: " + getArea();

return str;

}

public boolean equals(Circle c)

{

boolean status;

if(c.getRadius() == radius)

status = true;

else

status = false;

return status;

}

public boolean greaterThan(Circle c)

{

boolean status;

if(c.getArea() > getArea())

status = true;

else

status = false;

return status;

}

}

Explanation:

There is nothing with the logic of your code it work fine the problem is with the structure of your code you added an extra  curly brace before declaring (r)

****************************** Am talking about this section **********************

public class Circle {

{

private double radius;

****************************   It should be    *******************************************

public class Circle {

private double radius;

You might be interested in
In an SLR camera photogaphers look from the viewfinder through which of the following?
Fantom [35]
The answer is A mirror the lens
8 0
3 years ago
Read 2 more answers
The default case is required in the switch selection statement.
babunello [35]

Answer: False

Explanation:

 The given statement is false, as it is not compulsory that the default case is require in switch selection statement. If the default case are not properly specified in the statement then, there will be no execution occur in the switch selection statement.

It is sometimes good to have default case in switch selection statement, but it is not mandatory. The default case only executed when the correct case is present and none of the case matches in the given statement.

5 0
3 years ago
Make a hierarchical directory structure under /root that consists of one directory containing three subdirectories.
Alika [10]
You can make a hierarchical directory structure under /root that consists of one directory containing subdirectories  by using cd and mkdir
the mkdir command created the directories while the cd command changes which directory you're currently in
5 0
3 years ago
Which approach is ideal for ensuring that a Webpage is maintained and does not appear neglected to users?
Greeley [361]

Answer:

D

Explanation:

I think putting hyperlink in essential pages is a good idea as it may guide a user

8 0
3 years ago
Which of the following is Not included in the Web Accessibility Initiative? Don’t rely on color alone.
Doss [256]
I'm pretty sure it's D. Provide discount software for the underprivileged.
3 0
3 years ago
Other questions:
  • Why we can not see objects around us in the dark​
    6·1 answer
  • The set of instructions that directs the computer to perform a variety of tasks is known as a
    9·1 answer
  • THIS IS PYTHON QUESTION
    11·1 answer
  • ____ is a bundled set of communications services, including internet, telephone, and tv, that operates over a total fiber-optic
    5·1 answer
  • The MAA is responsible on a daily basis to protect office computers and patient records and personal information from hackers. R
    12·1 answer
  • Exchanging which type of data uses the least bandwidth?
    7·2 answers
  • Which of the following statements is TRUE?
    11·1 answer
  • You are implementing a RAID storage system and have found a system with eight 100 GB drives. How much storage space will you hav
    5·1 answer
  • What are the features of a computer speaker​
    10·1 answer
  • How to do the for loop in python
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!