answer.
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
astraxan [27]
2 years ago
4

Write an inheritance hierarchy of three-dimensional shapes. Make a toplevel shape interface that has methods for getting informa

tion such as the volume and surface area of a three-dimensional shape. Then make classes and subclasses that implement various shapes such as cubes, rectangular prisms, spheres, triangular prisms, cones, and cylinders. Place common behavior in superclasses whenever possible, and use abstract classes as appropriate. Add methods to the subclasses to represent the unique behavior of each three-dimensional shape, such as a method to get a sphere's radius.
Computers and Technology
1 answer:
kirill [66]2 years ago
7 0

Answer:

Check the explanation

Explanation:

Test.java

import javax.swing.*;

public class Test {

  public static void main( String args[] )

  {

     Point point = new Point( 7, 11 );        

     Square square = new Square( 3.5, 22, 8 );

     Cube cube = new Cube( 3.3, 10, 10 );

Shape[] arrayOfShapes = new Shape[ 3 ];

     String result = "";

arrayOfShapes[ 0 ] = point;

     arrayOfShapes[ 1 ] = square;

     arrayOfShapes[ 2 ] = cube;

result += point.getName() + ": " +

                   point.toString();

result += "\n" + square.getName() + ": " +

                   square.toString();

result += "\n" + cube.getName() + ": " +

                   cube.toString();

for ( int i = 0; i < 3; i++ ) {

        result += "\n" + arrayOfShapes[ i ].getName() +

           ": " + arrayOfShapes[ i ].toString();

         result += "\n" + "Area = " +

           arrayOfShapes[ i ].area();

        result += "\n" + "Volume = " +

           arrayOfShapes[ i ].volume();

     }

JOptionPane.showMessageDialog(

           null, result, "Shapes",

           JOptionPane.INFORMATION_MESSAGE );  

     System.exit( 0 );

  }

}  

Point.java

public class Point extends Shape {

  protected double x, y;

public Point( double a, double b ) { setPoint( a, b ); }

public void setPoint( double a, double b )

  {

     x = a;

     y = b;

  }

public double getX() { return x; }

public double getY() { return y; }

public String toString()

     { return "[" + x + ", " + y + "]"; }

public String getName() { return "Point"; }

}

Square.java

public class Square extends Point {

  protected double side;

public Square()

     { this( 0.0, 0.0, 0.0 ); }

public Square( double s, double a, double b )

  {

     super( a, b );

     setSide( s );

  }

public void setSide( double s )

     { side = ( s >= 0 ? s : 0 ); }

public double getSide() { return side; }

public double area() { return Math.pow( side, 2 ); }

public String toString()

     { return "Corner = " + super.toString() +

              "; side = " + side; }

public String getName() { return "Square"; }

}

Cube.java

public class Cube extends Square {

  private double depth;

public Cube( double s, double a, double b )

  {

     super( s, a, b );

     depth = s;

}

public double area() { return super.area() * 6; }

public double volume() { return super.area() * depth; }

public String toString()

     { return super.toString() + "; depth = " + depth; }

public String getName() { return "Cube"; }

}

Shape.java

public abstract class Shape {

  public double area() { return 0.0; }

  public double volume() { return 0.0; }

  public abstract String getName();  

}

You might be interested in
Give a recursive (or non-recursive) algorithm to compute the product of two positive integers, m and n, using only addition and
LiRa [457]

Answer:

Multiply(m,n)

1. Initialize product=0.

2. for i=1 to n

3.      product = product +m.

4. Output product.

Explanation:

Here we take the variable "product" to store the result m×n. And in this algorithm we find m×n by adding m, n times.

6 0
2 years ago
Look at the top 3 banking activities done via mobile banking vs. online banking. What characteristics do you notice for both?
muminat

Answer:  <em>The biggest difference between the two is their functionality. Internet Banking allows you to conduct online transactions through your PC or laptop and an internet connection. On the other hand, mobile banking can be done with or without internet. Many banks nowadays have their mobile apps for mobile banking.</em>

Disadvantages of Mobile Banking

<em>If the customer does not have a smartphone than the use of Mobile Banking becomes limited. A transaction like transfer of funds is only available on high-end phones. Regular use of Mobile Banking may lead to extra charges levied by the bank for providing the service.</em>

<em />

Explanation: <u><em>Was this helpful to you? if so please put me Brainlyest.</em></u>

4 0
2 years ago
In three to four sentences, describe why CEOs (the chief executive officers, that is, the leaders of large companies) make very
mixer [17]
Well, CEOs are on the top of the food chain. It takes a lot of work and ambition to become one, and once they are one, <span>CEOs accept a huge amount of responsibility - that means having to take blame if things go wrong and </span><span>having more tasks to complete such as having to attend numerous meetings, make decisions. They are also on the board of directors.</span>

Assistants do not have to do as much, they likely won't have that much responsibility or experience, their tasks revolve around ensuring meetings are scheduled and performing other ad-hoc duties.
5 0
2 years ago
In the simulation, player 2 will always play according to the same strategy. The number of coins player 2 spends is based on wha
baherus [9]

The simulation, player 2 will always play according to the same strategy.

Method getPlayer2Move below is completed by assigning the correct value to result to be returned.

Explanation:

  • You will write method getPlayer2Move, which returns the number of coins that player 2 will spend in a given round of the game. In the first round of the game, the parameter round has the value 1, in the second round of the game, it has the value 2, and so on.

#include <bits/stdc++.h>  

using namespace std;

bool getplayer2move(int x, int y, int n)  

{

   int dp[n + 1];  

   dp[0] = false;  

   dp[1] = true;  

   for (int i = 2; i <= n; i++) {  

       if (i - 1 >= 0 and !dp[i - 1])  

           dp[i] = true;  

       else if (i - x >= 0 and !dp[i - x])  

           dp[i] = true;  

       else if (i - y >= 0 and !dp[i - y])  

           dp[i] = true;  

       else

           dp[i] = false;  

   }  

   return dp[n];  

}  

int main()  

{  

   int x = 3, y = 4, n = 5;  

   if (findWinner(x, y, n))  

       cout << 'A';  

   else

       cout << 'B';  

   return 0;  

}

8 0
2 years ago
The geographic coordinate system is used to represent any location on Earth as a combination of latitude and longitude values. T
Pachacha [2.7K]

Answer:

Here is the script:  

function dd = functionDMS(dd)  

prompt= 'Enter angle in DD form ';

dd = input(prompt)

while (~checknum(dd))

if ~checknum(dd)

error('Enter valid input ');

end

dd = input(prompt)

end  

degrees = int(dd)

minutes = int(dd - degrees)

seconds = ( dd - degrees - minutes / 60 ) * 3600  

print degrees

print minutes

print seconds

print dd

Explanation:

The script prompts the user to enter an angle in decimal degree (DD) form. Next it stores that input in dd. The while loop condition checks that input is in valid form. If the input is not valid then it displays the message: Enter valid input. If the input is valid then the program converts the input dd into degrees, minutes and seconds form. In order to compute degrees the whole number part of input value dd is used. In order to compute the minutes, the value of degrees is subtracted from value of dd. The other way is to multiply remaining decimal by 60 and then use whole number part of the answer as minutes. In order to compute seconds subtract dd , degrees and minutes values and divide the answer by 60 and multiply the entire result with 3600. At the end the values of degrees minutes and seconds are printed. In MATLAB there is also a function used to convert decimal degrees to degrees minutes and seconds representation. This function is degrees2dms.

Another method to convert dd into dms is:

data = "Enter value of dd"

dd = input(data)

degrees = fix(dd);

minutes = dd - degrees;

seconds = (dd-degrees-minutes/60) *3600;

8 0
2 years ago
Other questions:
  • The matrix theory is used in the ___ technique
    8·1 answer
  • Consider the following code: x = 17 y = 5 print (x % y) What is output?
    10·1 answer
  • Define a function PyramidVolume with double parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the vo
    7·2 answers
  • Which of the following is a collection of unprocessed items, which can include text, numbers, images, audio, and video?A. DataB.
    14·1 answer
  • 3.A customer has a system with a Gigabyte B450 Aorus Pro motherboard. He wants to upgrade the processor from the AMD Athlon X4 9
    11·1 answer
  • Write a split check function that returns the amount that each diner must pay to cover the cost of the meal The function has 4 p
    14·1 answer
  • Which of the following is not an advantage of a flowchart?
    15·1 answer
  • Summary: Given integer values for red, green, and blue, subtract the gray from each value. Computers represent color by combinin
    11·1 answer
  • In this exercise you will debug the code which has been provided in the starter file. The code is intended to take two strings,
    7·1 answer
  • Most ________ are accompanied by several common utility programs, including a search program, a storage management program, and
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!