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
Evgesh-ka [11]
3 years ago
10

. Write a toString method for this class. The method should return a string containing the base, height and area of the triangle

. b. Write an equals method for this class. The method should accept a Triangle object as an argument. It should return true if the argument object contains the same data as the calling object, or false otherwise. c. Write a greaterThan method for this class. The method should accept a Triangle object as an argument. It should return true if the argument object has an area that is greater than the area of the calling object, or false otherwise.
Computers and Technology
1 answer:
marta [7]3 years ago
7 0

Answer:

Check the explanation

Explanation:

Circle.java

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;

}

}

I have created a class also to test this class below is the class: -

MainCircle.java

public class MainCircle {

public static void main(String args[]) {

Circle c = new Circle(2.5);

Circle c1 = new Circle(2.5);

Circle c2 = new Circle(4.5);

System.out.println(c);

System.out.println(c1);

System.out.println(c2);

System.out.println("Is c and c1 equal : "+c.equals(c1));

System.out.println("Is c2 greater than c1 : "+c1.greaterThan(c2));

}

}

Output: -

Radius: 2.5Area: 19.634954084936208

Radius: 2.5Area: 19.634954084936208

Radius: 4.5Area: 63.61725123519331

Is c and c1 equal : true

Is c2 greater than c1 : true

You might be interested in
Why is it important to brain storm and develop concepts prior to selecting an idea that you wish to move forward with as a solut
kupik [55]

Answer:

Brainstorming helps you develop creative solutions to a problem, and is particularly ... And while it's important to start with a structured, analytical process when solving ... However, you may not develop ideas as fully when you're on your own, because ... To get the most out of your individual brainstorming session

4 0
3 years ago
A smart refrigerator can use _____ to detect when you are running low on milk, and then send a reminder to you on a wireless net
Brilliant_brown [7]

Answer:

IoTs

Explanation:

4 0
3 years ago
One item you will NOT need to provide when opening up a bank account
gladu [14]

Answer:

You don't need a birth certificate

Explanation:

8 0
3 years ago
Read 2 more answers
Why might it be a good idea to choose a bus topology?
Shtirlitz [24]

Answer:A

Explanation: Its cheap and easy to install

7 0
3 years ago
Read 2 more answers
Which Of the following components leads to slow computer performance when it becomes outdated
Scorpion4ik [409]

guess its d drivers , since u said wen it gets outdated


8 0
3 years ago
Read 2 more answers
Other questions:
  • Write a function that takes an array of integers and its size as parameters and prints the two largest values in the array. In t
    5·1 answer
  • What is the purpose of a title slide on power point
    14·2 answers
  • What considerations have to be kept in mind with JPEG
    10·1 answer
  • Write a python program that requests a word (with lowercase letters) as input and translates the word into pig latin. The rules
    15·2 answers
  • What is an example of how pseudo - randomness is used to creative variation​
    5·1 answer
  • What are features of a product?
    8·2 answers
  • What has information technology made piracy possible?
    14·1 answer
  • Potatocat2UwU da best
    12·1 answer
  • If you wanted to have wireless connectivity in your home or​ apartment, you would need a​ _________________ to move packets of d
    11·1 answer
  • A 9-year old male castrated Westie presents on emergency after being rescued from a house fire. On presentation, the dog has a r
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!