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
This is a quick and easy program that will let you practice the basics of the switch statement. You will ask the user to enter a
Nikolay [14]

Answer:

Explanation:

oof okay

5 0
3 years ago
Climatologist use weather balloons, stethoscopes, and satellites true or false
Nonamiya [84]

Answer:

False.

Explanation:

A stethoscope is a medical instrument which is used for listening to the work of the heart and lungs.  It consists of a microphone that rests on the patient's chest, and rubber tubes that bring the sound to the earphones. An ordinary stethoscope does not have any moving or electrical parts, as it only mechanically conducts sound from the patient's chest to the doctor's ear.   One of the simplest examinations that doctors perform today is listening to the lungs and heart with a stethoscope. With the help of this instrument, noises are heard during the work of the lungs and heart.

8 0
2 years ago
What is microsoft certification?
BabaBlast [244]
Microsoft certification is a series of programs that provide certification of competence in Microsoft products.
6 0
3 years ago
What is the advantage of using the Publish Online option for sharing a calendar? It creates a web version that can be viewed by
kotykmax [81]

Answer:

its D. it allows a user outside an organization to view the calendar.

Explanation:

i just got it right on edge 2020.

7 0
2 years ago
Read 2 more answers
um I'm new and I just sign up like right now and brainly says I've reached my daily limit for my questions why?
Natalija [7]

Answer:

Im not sure why but maybe you can find a way to contact the people who own it and see if they know because that hasn't happened to me. How many questions have you asked

Explanation:

7 0
3 years ago
Other questions:
  • Mark had been a resident of Larchmont for 17 years, and local folks thought of him as a solid citizen. "In this sentence, the wo
    7·2 answers
  • When selecting font size in a document, ____ points equals one-inch-tall text?
    10·1 answer
  • If an M/M/1 queue in a server has task arrivals at a rate of 30 per second and serves at a rate of 50 per second, how many tasks
    10·1 answer
  • You want to make it possible for your smartphone to share its internet access wirelessly with your friends device which of the f
    10·1 answer
  • The ash and dust from a volcanic eruption can cause a ______ change in the environment.
    8·1 answer
  • When gathering information about certain occupations, be sure to understand how you are paid. What is the difference between a s
    12·2 answers
  • BEING TIMED HELP ASAP
    12·2 answers
  • Which objects appear on the slide after she clicks OK? Check all that apply.
    13·1 answer
  • In python 3.17 LAB: Convert to dollars
    14·1 answer
  • What is wrong with the following code? publicstatic char grade(int score) { if (score >= 9) { return 'A'; } else if (score &g
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!