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
You use worksheets to perform calculations. How do you perform these calculations?
Elena-2011 [213]
The main function you will use is.... Type SUM= in all caps into a cell and then you can control click cells to add them together. You can also add PEMDAS properties to do calculations withing it.
5 0
3 years ago
Read 2 more answers
Write a recursive function is_pow2(n) that returns True if the positive integer n is an integer power of 2, and False otherwise.
bezimeni [28]

Answer:

In Python:

def is_power(n):

   if n > 2:

       n = n/2

       return is_power(n)

   elif n == 2:

       return True

   else:

       return False

Explanation:

This defines the function

def is_power(n):

If n is greater than 0

   if n > 2:

Divide n by 2

       n = n/2

Call the function

       return is_power(n)

If n equals 2

   elif n == 2:

Return True

       return True

If n is less than 2

   else:

Then, return false

       return False

8 0
3 years ago
Using a "word" of 5 bits, list all of the possible signed binary numbers and their decimal equivalents that are represent able i
Vsevolod [243]

Answer:

i). Signed magnitude

Five bit representation = 11111

For positive 5 bit representation = 01111 = +15

For negative 5 bit representation = 11111 = -15

ii). One's complement

For positive 5 bit representation = 01111 =+15

For negative 5 bit representation = 10000 = -15

iii). Two's compliment

For positive 5 bit representation = 01111 = -15

For negative 5 bit representation = 10001 = +15

7 0
3 years ago
) Consider the array called myArray declared below that contains and negative integers. Write number of positive integers in the
grigory [225]

Answer:

#include <iostream>

using namespace std;

int main()

{

 

  int arr[]={3,-9,9,33,-4,-5, 100,4,-23};

  int pos;

  int n=sizeof(arr)/sizeof(arr[0]);

  for(int i=0;i<n;i++){

      if(arr[i]>=0){

          pos++;

      }

  }

  cout<<"Number of positive integers is "<<pos<<endl;

  return 0;

}

Explanation:

create the main function in the c++ programming and declare the array with the element. Then, store the size of array by using the formula:

int n=sizeof(arr)/sizeof(arr[0]);

after that, take a for loop for traversing the array and then check condition for positive element using if statement,

condition is array element greater than or equal to zero.

if condition true then increment the count by 1.

this process happen until the condition true

and finally print the count.

6 0
3 years ago
What are the four conditions to help determine whether a website is a good source for information?
Ratling [72]

Answer:

1. Credible Websites are Registered with Legitimate Institutions 2. Watch out for Dummy Content for Website Credibility Check 3. Watch out for Scam Advertisements to Verify Website Credibility 4. Professional Designs Mean Everything

Explanation:

3 0
2 years ago
Other questions:
  • Brainliest to whoever can guess what year this corvette logo is from. Make your guesses
    11·1 answer
  • Marcus just created a new folder specifically for his buisness records so he would like to move last months business transaction
    13·2 answers
  • Correspondence involves verbal communication. True False
    6·2 answers
  • Which of the following is a school-to-work program that provides the student with paid employment, school credit, and school gra
    7·2 answers
  • Research information technology affects on job market, career pathways, occupational outlooks in business and finance and synthe
    7·1 answer
  • Suddenly, though, just as the procedure was about to be relayed to the astronauts, the pressure . . . the temperature . . . drop
    5·2 answers
  • How can a user access the Mailbox Cleanup tools?
    11·2 answers
  • 9. These particular machines can be decentralized.
    9·1 answer
  • A trace table is used for
    5·2 answers
  • Another name of computer program is
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!