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
Sort short_names in reverse alphabetic order.
tangare [24]

lst = short_names.split()

print(sorted(lst,reverse = True))

6 0
3 years ago
How does the purchase of office equipment on account affect the accounting equation?
Nina [5.8K]
A. Assets increase, and liabilities decrease.
6 0
3 years ago
Read 2 more answers
Explain how QoS might be implemented
Artist 52 [7]

Answer:

 The quality of service basically provide the sufficient quality in the IP network and it is also known as traffic shaping. As, it assign the priority to every device and the services in the network. It basically recognize the several types of the traffic moving in the network.

The implementation of quality of service is basically done in many network applications by reserve the bandwidth and specific path in the network system.

The various network device control the packet flow so that the network resources can easily accept packets in the network.

 

 

6 0
3 years ago
github Portfolio Balances An investor opens a new account and wants to invest in a number of assets. Each asset begins with a ba
OLEGan [10]

The following code will be used to determine the maximum amount invested

<u>Explanation:</u>

long maxValue(int n, int rounds_rows, int rounds_columns, int into rounds)

{

   // Define the variable to store

   // the maximum amount invested.

   long max = 0;

   

   // Define an array of size n,

   // to store the n investments.

   long *investments = (long*)malloc(sizeof(long)*n);

   int i=0;  

   // Initially set all

   // the investments to 0.

   for(i=0;i<n;i++)

   {

       investments[i] = 0;

   }

   i=0;

   // Run the loop to

   // perform the rounds.

   while(i<rounds_rows)

   {

       // Get the left value

       // of the current round.

       int left = rounds[i][0];

       

       // Get the right value

       // of the current round.

       int right = rounds[i][1];

       // Get the contribution

       // for the current round.

       int contribution = rounds[i][2];

       // Since the user uses 1-based

       // indexing, subtract 1 from left

       // and right as the program uses

       // 0-based indexing. That is, the

       // investments in the array start

       // from 0 and not 1.

       right = right - 1;

       int j=0;

       // Run the loop to add the

       // contribution to all the investments

       // between left and right, both inclusive.

       for(j=left; j<=right; j++)

       {

           investments[j] += contribution;

       }

       i++;

   }

   // Traverse the investments array

   // to find the maximum element.

   max = investments[0];

   for(i=1; i<n;i++)

   {

       if(investments[i]>max)

       {

           max = investments[i];

       }

   }

   // Return the

   // maximum investment.

   return max;  

}

6 0
4 years ago
How to transfer audio files from computer to android?
fenix001 [56]
U can use Bluetooth connect your computer to the android. <span />
5 0
4 years ago
Other questions:
  • You are entering command that operates on a file. The path to the file is lengthy and confusing and you are afraid that you will
    12·1 answer
  • Ive looked everywhere on brainly and we have no answers for computers and technology
    7·1 answer
  • Which company operates a public cloud?<br><br> Lotus<br> Acme<br> Google<br> Symantec
    5·2 answers
  • For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
    9·1 answer
  • What can u access various sites on
    12·1 answer
  • Which of the following can be represented by a single binary digit?
    14·1 answer
  • Write the algorithm for finding the perimeter of a rectangle using English like form step by step
    10·1 answer
  • How can i fix a all white phone screen
    11·2 answers
  • A debate about city schools are more better than village schools​
    8·1 answer
  • How does 5G technology enhance the Internet of Things (ioT) ?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!