Euclidean geometry, a rhombus a is a simple quadrilateral whose four sides all h
ID: 3827988 • Letter: E
Question
Euclidean geometry, a rhombus a is a simple quadrilateral whose four sides all have the same length lengths of each of the sides are a and the distance between the parallel sides (known as height) is h. the area of the rhombus is defined as a times h. Suppose that you already have a class named Rhombus that can hold a and h. The class has a method to compute the area as well. The class is as follows. public class Rhombus { private double a, h; Rhombus nextRhombus; Rhombus( ) { h = 1; a = h; Rhombus (double aa, double hh){ a = aa; h = hh; } public double geta( ){ return a; } public double geth( ){ return h; public double getArea( ){ return h; } public double getArea( ){ rturn a*h; } public boolean isSquare( ){ return a == h; } } Notice that Rhombus nextRhombus; in the Rhombus class can be used to construct a linked list. (a) Now, you have another class named RhombusProcessor that has Rhombus objects in an array in the main method. Write a method named getsquares in the Rhombusprocessor class to copy only the Rhombus objects that represent squares. The getsquares method must return t square shaped Rhombus objects using a linked list in the same oder they appear in the original list. Notice that you will only return the head of the linked list. The program is partially written: you just need to write the getsquares in the space provided within the RhombusProcessor class. The expected header is public static Rhombus getsquares (Rhombus[ ] r).Explanation / Answer
class RhombusProcessor extends Rhombus
{
int result;
public static Rhombus getSquares(Rhombus[] r)
{
result=(a*a)+(h*h);
System.out.println("Rhombus Squares: "+result);
}
Rhombus r=new Rhombus(4.5,6.5);
r.geta();
r.geth();
r.getArea();
r.isSquare();
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.