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
A device used to measure the pressure of an enclosed gas is a manometer.<br> a. True<br> b. False
Taya2010 [7]
Its true, check it out here 

manometer
nounan instrument for measuring the pressure acting on a column of fluid, consisting of a U-shaped tube of liquid in which a difference in the pressures acting in the two arms of the tube causes the liquid to reach different heights in the two arms.
4 0
3 years ago
PLEASE HELP ME WITH MY UNIT TEST!!!!!!!!!!!!!! I'M STRUGGLING AND I AM ESPECIALLY STUCK ON THIS ONE!!!!!!!!!!!!!!!!!!!!!! FOR BR
Nikitich [7]

A company’s technology policy applies only to the Internet usage of employees

I’m not sure if it right so sorry if it wrong!

7 0
3 years ago
Programmers use a(n) ____ when they need the computer to repeatedly process one or more program instructions until some conditio
Arlecino [84]

Answer:

Loop

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

Programmers use a(n) <u>loop</u> when they need the computer to repeatedly process one or more program instructions until some condition is met, at which time the <u>loop</u> ends.

<u><em>Loops</em></u> repeat a certain set of instructions until a certain condition is acuired and then exit out of the loop. There are a couple of different types of loops such as For Loop, While Loop, and Do-While loop. Each repeats a set of instructions but for a different set of times.

<u><em>For Loops</em></u> repeat for a fixed amount of Times or until the condition is met and it breaks out of the loop. Meanwhile,  <em><u>While</u></em> and <em><u>Do-While</u></em> loops keep repeating until the condition is me, but the Do-While checks the condition at the end of the loop.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

5 0
3 years ago
Main topics: Basic Java program
bazaltina [42]

Answer:

Explanation:

import java.util.Scanner;

public class pitcherValues {

   public static void main(String[] args) {

       String firstName, lastName;

       int earnedRuns, inningsPitched;

       double ERA;

      Scanner in = new Scanner(System.in);

     System.out.println("Pitchers First Name is?");

     firstName = in.nextLine();

     System.out.println("Pitchers Last Name is?");

     lastName = in.nextLine();

     System.out.println("How many runs did the Pitcher earn?");

     earnedRuns = in.nextInt();

     System.out.println("How many innings did the Pitcher Pitch?");

     inningsPitched = in.nextInt();

     ERA = (earnedRuns * 9) / inningsPitched;

     System.out.println(firstName + " " + lastName + " has an ERA of " + ERA);

   }

}

3 0
3 years ago
Define the following:-<br><br>1) cryptography<br><br>2) Quantum Cryptography​
Readme [11.4K]
1.) the art of writing or solving codes.
2.) the science of exploiting quantum mechanical properties to perform cryptographic tasks.

hope this helps :)
8 0
3 years ago
Read 2 more answers
Other questions:
  • Explain how it makes you feel that you must share the road with others
    15·1 answer
  • M
    15·1 answer
  • Write a program that prompts the user to enter the number of integer numbers you need to enter, then ask user to enter these int
    5·1 answer
  • Explain the applications software that you use everyday
    5·1 answer
  • If i took my SIM card out of my phone and put it in a router then connect the router and my phone with Ethernet cable would the
    12·1 answer
  • By what other name can the folders in Windows 7 be called?
    5·1 answer
  • As you explore career options why is it important to take personal inventories and assessments
    5·2 answers
  • Is this a desktop or a computer, or are they the same thing
    12·1 answer
  • Inputs and outputs that allow a user to interact<br> with a piece of software
    14·2 answers
  • which filename refers to a 16-bit real-mode program that queries the system for device and configuration data, and then passes i
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!