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]
3 years ago
12

Given the Solid class, extend it with:

Computers and Technology
1 answer:
andreev551 [17]3 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
Task1: #Define a function called show_students which takes 2 parameters students and message #Print out a message, and then the
k0ka [10]

Answer:

  1. def show_students(message, sList):
  2.    print(message)
  3.    print(sList)
  4.    print("Our students are currently in alphabetical order")
  5.    sList.sort()
  6.    output = ""
  7.    for student in sList:
  8.        output += "-" + student
  9.    print(output)
  10.    print("Our students are currently in reverse alphabetical order")
  11.    sList.sort(reverse=True)
  12.    output = ""
  13.    for student in sList:
  14.        output += "-" + student
  15.    print(output)  
  16. show_students("Welcome to new semester!", ["Aaron","Bernice", "Cody"])

Explanation:

Firstly we declare a function that will take two inputs, message and student list (Line 1).

In the function, we first print the message and the original input student list (Line 2 - 3). Next, we use sort method to sort the input list and then output the sorted items from the list using a for loop (Line 5-10).

Next, we sort the list again by setting reverse = True and this will sort the list in descending order (Line 13). Again we use the similar way mentioned above to output the sorted items (in descending order) using a for loop (Line 14 -17)

We test the function using a sample student list (Line 18) and we shall get the output:

Welcome to new semester!

['Aaron', 'Bernice', 'Cody']

Our students are currently in alphabetical order

-Aaron-Bernice-Cody

Our students are currently in reverse alphabetical order

-Cody-Bernice-Aaron

6 0
3 years ago
Damage to which portion of the limbic system results in loss of memory of recent events and difficulty committing anything new t
Vera_Pavlovna [14]

Answer:

Hippocampus.

Explanation:

There are two parts of the limbic system. They are the frontal part which is the amygdala and the posterior part which is the hippocampus.

The hippocampus is an extension of the temporal part  of the cerebral cortex which is a plastic-like structure that can be easily damaged by stimuli. It is packed with densed neurons and forms an S-shape at the extension of the temporal part.

It is responsible for learning and memory and damage to it can result to memory loss of recently learnt information.

8 0
3 years ago
Indonesia is planning to move its capital from Jakarta to the island of Borneo in the hope that the burden of congestion, regula
JulijaS [17]

Answer:

Indonesia's capital has just been relocated from Jakarta to a site within the jungle of Kalimantan on Borneo island after parliament approved the bill. It will strengthen supply chains and place Indonesia "in a more strategic position in world trade routes, investment flows, and technological innovation."

Explanation:

mark as brainiest

6 0
2 years ago
Read 2 more answers
Which of the following is an acrostic
Darina [25.2K]
There is no option........................................
5 0
4 years ago
Which of the following is not a data type available in VB.NET?
deff fn [24]
The obvious answer to your question: Which of the following is not a data type available in vb.net is OPERATOR. Integers, strings, and date time are all data types. They are commonly used to store data accordingly to what type they are.
6 0
3 years ago
Other questions:
  • When saving a document or drawing, you determine the destination folder in which the file will be saved by?
    6·1 answer
  • A technology company only hires applicants who are under the age of 30. This company could face possibly _________ consequences
    9·2 answers
  • How can a user begin working with a new, blank workbook in Excel?
    10·1 answer
  • Type the correct answer in the box. Spell the word correctly. Which framework can be used to develop cross-platform applications
    15·2 answers
  • Write a single if-test using Boolean operators and relaional operators to determine if a double variable x is between zero (excl
    11·1 answer
  • Write a couple of paragraphs about the usefulness of computer​
    5·1 answer
  • And this help me please as well. ​
    12·1 answer
  • Está dentro del gabinete del CPU es electrónica y hace que la transferencia de datos se realice contra gran rapidez / ayuda vien
    6·1 answer
  • What are three major events in computer science history?
    11·2 answers
  • Which of the following file formats allows you to share and save documents
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!