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
maks197457 [2]
2 years ago
12

Given the Solid class, extend it with:

Computers and Technology
1 answer:
andreev551 [17]2 years ago
6 0

Answer:

Following are the code to this question:

Explanation:

//For Solid:

public class Solid//defining a class Solid

{

private String myName;//defining a String variable

public Solid(String name)//defining parameterized constructor

{

myName = name;//holding String value in myName variable

}

public String getName()//defining getName method  

{

return myName;//return value of myName

}

public double volume()//defining method volume that overriden its subclass

{

return 0;//return value

}

public double surfaceArea()//defining method surfaceArea that overriden its subclass

{

return 0;//return value

}

}

//For RectangularPrism:

public class RectangularPrism extends Solid//defining a class RectangularPrism that inherits Solid

{

  protected double length,width,height;//defining double variable

RectangularPrism(String str,double l,double w,double h)//defining parameterized constructor

{

  super(str);//use super method

  this.length=l;//use this to hold value

  this.width=w;//use this to hold value

  this.height=h;//use this to hold value

}

public double volume()//defining volume method  

{

return length*width*height;//calculate and return volume value

}

public double surfaceArea()//defining a  method surfaceArea  

{

return 2*(length*width+width*height+height*length);//calculate and return the surfaceArea

}

}

// For  Cube:

public class Cube extends RectangularPrism//defining Cube class that inherits RectangularPrism  

{

  Cube(String name, double side) //defining parameterized constructor

   {

       super(name, side, side, side);//use super method

   }

  public double volume()//defining volume method  

  {

   return length * length * length;//calculate and return volume

  }

public double surfaceArea()//defining method surfaceArea  

  {

  return 6 * length*length;//calculate and return surfaceArea

   }

}

//for Cylinder:

import java.lang.*;//import lang package  

public class Cylinder extends Solid//defining Cylinder class that inherits Solid

{

  private double radius, height;//defining double variable

  public Cylinder(String str, double r, double h)//defining parameterized constructor

  {

      super(str);//use super Method

      this.radius = r;//use this keyword to hold value

      this.height = h;//use this keyword to hold value

  }

  public double volume()//defining volume method

  {

      return Math.PI * radius * radius * height;//calculate and return volume

  }

  public double surfaceArea()//defining surfaceArea method

  {

     return 2 * Math.PI * radius * (height + radius);//calculate and return surfaceArea

  }

}

//For Pyramid

import java.lang.*;//import package

public class Pyramid extends Solid//defining a Pyramid class that inherits Solid

{  

  private double length, width,height;//defining double variable

  public Pyramid(String str, double l, double w, double h)//defining parameterized constructor  

  {

      super(str);//use super method

      this.length = l;//use this keyword to hold value

      this.width = w;//use this keyword to hold value

      this.height = h;//use this keyword to hold value

  }

public double volume()//defining volume method

{

return (length*width*height)/3.0;//calculate and return volume

}

public double surfaceArea()//defining a method surfaceArea

{

return (length*width)+length*Math.sqrt((Math.pow((width/2),2)+(height*height)))+(width*Math.sqrt((Math.pow((length/2),2)+(height*height))));//calculate and return surfaceArea

}

}

//For Sphere

import java.lang.*;//import package

public class Sphere extends Solid //defining Sphere class that inherits Solid

{

  private double radius;//defining double variable

  public Sphere(String str, double r)//defining parameterized constructor  

  {

      super(str);//use super method

      this.radius = r;//use this to hold value

  }

  public double volume()//defining volume method

  {

      return (4.0/3.0)*Math.PI*radius*radius*radius;//calculate and return volume

  }

  public double surfaceArea()//defining method surfaceArea  

  {

    return 4 * Math.PI * radius * radius;//calculate and return surfaceArea

  }

}

please find attachment.

You might be interested in
What is the difference between HTML and XML?
Luba_88 [7]

Explanation:

HTML displays data and describe the structure of a webpage while XML stores and transfers data.

7 0
2 years ago
If Anime Characters were real , Who Would Your Anime Wife Would Be (Tell Who And Why)
ehidna [41]

Answer:

Runa, because  she’s like me I r l lol

Explanation:

3 0
2 years ago
When excel imports an access table, the data is placed in a worksheet _____?
ratelena [41]
Book is the answer!!!!!
3 0
3 years ago
How do I add a Child to my Brainly account
ratelena [41]

Answer:

i think you might have to just make adjfferent one for thenm a sepeet account. but im not sure atleast ive never seen anywere if you can add someo e else to the same account.

5 0
1 year ago
Many who enter the field of information security are technical professionals such as __________ who find themselves working on i
Fynjy0 [20]

Answer:

networking experts or systems administrators ,database administrators,programmers.

Explanation:

The people who enter in the field of information security are professionals in technical fields bu their work is totally into the field of security like working on security applications.They don't work on the traditional IT assignments such as developing software,apps,website etc.

3 0
2 years ago
Other questions:
  • What is a function library?
    11·1 answer
  • An example of an email client is:<br> A.)Yahoo<br> B.)Gmail<br> C.)Outlook<br> D.)All of the Above
    9·1 answer
  • P3. In Section 4.2 , we noted that the maximum queuing delay is (n–1)D if the switching fabric is n times faster than the input
    8·1 answer
  • You will be given a string, containing both uppercase and lowercase alphabets(numbers are not allowed).
    14·1 answer
  • What was the first fully computer animated feature film?
    13·1 answer
  • IN THE MOVIE BACK TO THE FUTURE 1985 IS 1985 THE PUBLICATION DATE?WHERE CAN I FIND THE MOVIE?
    6·1 answer
  • How many inches do a tire have to be to sometimes be refer as bald of balding tries
    14·1 answer
  • How much time per day does the average U.S. youth spend watching television, playing video games, or using a computer?
    8·1 answer
  • What is information associated with a document to help describe that document called?
    14·1 answer
  • You have been elected to assist the school's yearbook committee and newspaper club in purchasing new computers. The current comp
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!