1. Write a Calculatable interface that includes methods to calculate the following. (Do not overanalyze these methods!)

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

1. Write a Calculatable interface that includes methods to calculate the following. (Do not overanalyze these methods!)

Post by answerhappygod »

1. Write a Calculatable interface that includes
methods to calculate the following. (Do not
overanalyze these methods!)
The volume of a cube. The volume of a cube is determined by the
length, height, and width.
The volume of a cylinder. The volume of a cylinder is determined by
the height and radius of a
cylinder.
2. Consider the following partially completed
class.
public class SomeClass extends SomeOtherClass
{
public void convertHours(double hours)
{
//some code here
}
public void convertMonths(double months)
{
//some code here}
}
}
Write the corresponding abstract class.
3. Consider the following partially complete class:
public class TestClass implements Comparable
{
private String lastName;
private String firstName
public TestClass( String lastName, String firstName)
{
this.lastName=lastName;
this.firstName=firstName;
}
public String getlastName()
{
return this.lastName;
}
public String getFirstName()
}
return this.firstName;
}
public int compareTo( Object obj)
{
// complete the code here
}
}
Using the Comparable interface, write a compareTo()
method that returns -1 if the private
instance variable lastName occurs lexicographically before obj,
0 if the private instance
variable lastName and obj are lexicographically the same, or 1 if
the private instance variable
lastName occurs lexicographically after obj. Use a getter method
any time you need to use a
private instance variable.
Thank You!
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply