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
Mariulka [41]
3 years ago
8

Define a method pyramidVolume with double parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the volu

me of a pyramid with a rectangular base. Relevant geometry equations: Volume
Computers and Technology
1 answer:
marysya [2.9K]3 years ago
7 0
<h2>Question:</h2>

Define a method pyramidVolume with double parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the volume of a pyramid with a rectangular base. Relevant geometry equations:

Volume = base area x height x 1/3

Base area = base length x base width.

(Watch out for integer division)

import java.util.Scanner;

public class CalcPyramidVolume {

   /* Your solution goes here */

   public static void main (String [] args) {

     System.out.println("Volume for 1.0, 1.0, 1.0 is: " + pyramidVolume(1.0, 1.0,   1.0));

     return;

    }

}

<h2>Answer:</h2><h2></h2>

import java.util.Scanner;

public class CalcPyramidVolume {

   /* Your solution goes here */

   public static void main (String [] args) {

       System.out.println("Volume for 1.0, 1.0, 1.0 is: " + pyramidVolume(1.0, 1.0, 1.0));

       return;

   }

   

   //Begin method definition

   public static double pyramidVolume(double baseLength, double baseWidth, double pyramidHeight){

       

       //First, calculate the base area of the pyramid

       //store the result in a double variable

       double baseArea = baseLength * baseWidth;

       

       //Then, calculate the volume of the pyramid

       //using the base area and the base width

       double volume = 1 / 3.0 * baseArea * pyramidHeight;

       

       //return the volume

      return volume;

   }

}

<h2>Output:</h2>

Volume for 1.0, 1.0, 1.0 is: 0.3333333333333333

<h2>Explanation:</h2>

The code above contains comments explaining the important lines of the code. The output of the code has also been provided above.

The parts of the code that are worth noting are:

(i) The return type of the method pyramidVolume should be a <em>double</em> since calculations are done using <em>double</em> values. i.e the method header should be written as

<em>public static double pyramidVolume(){</em>

<em>}</em>

<em />

(ii) The method requires three(3) parameters of type double: baseLength, baseWidth and pyramidHeight. These should be included in the method. Therefore, the complete header definition should be:

<em>public static double pyramidVolume(double baseLength, double baseWidth, double pyramidHeight){</em>

<em />

<em>}</em>

(iii) The formula for calculating the volume of the pyramid should be:

volume = 1 / 3.0 * baseArea * baseWidth;

Rather than;

volume = 1 / 3 * baseArea * baseWidth;

This is because integer division yields integer result. If 1 / 3 is evaluated, the result will be 0 since the decimal part will be truncated thereby making the result of the volume = 1 / 3 * baseArea * baseWidth will be 0.

Therefore, the work around for that should be to write 1 / 3.0 or 1.0 / 3.0 or 1.0 / 3.

(iv) After the calculation, the result of volume should be returned by the method. This will enable a proper call by the main method for execution.

You might be interested in
What are price comparison websites?
Wittaler [7]

Answer:

A comparison shopping website, sometimes called a price comparison website, price analysis tool, comparison shopping agent, shopbot, aggregator or comparison shopping engine, is a vertical search engine that shoppers use to filter and compare products based on price, features, reviews and other criteria.

<h3><u>PLEASE</u><u> MARK</u><u> ME</u><u> BRAINLIEST</u><u>.</u></h3>
8 0
3 years ago
9.
Liula [17]

Answer:

128 is ur answer

Explanation:

please mark me as brainilist

5 0
2 years ago
What command utilizes the limpel-ziv (lz77) compression algorithm and achieves a compression ratio of 60-70 percent?
AURORKA [14]

The limpel-ziv (lz77) compression technique is used by the GNU zip (gzip) tool to produce a compression ratio of 60–70%.

<h3>How do methods for data compression function? Describe the LZW algorithm.</h3>

Compression methods lower the amount of memory needed to hold pictures and the number of bytes needed to represent data. Compression improves the amount of data that can be delivered over the internet and enables the storage of more photos on a given media.

Abraham Lempel, Jacob Ziv, and Terry Welch developed the table-based lookup technique known as LZW compression to compress a file into a smaller file. The TIFF image format and the GIF image format are two frequently used file formats that employ LZW compression.

To know more about limpel-ziv (lz77) compression algorithm, Visit:

<u>brainly.com/question/19878993</u>

#SPJ4

4 0
2 years ago
A compression scheme for long strings of bits called run-length encoding is described as follows: Rather than record each 0 and
Musya8 [376]

Answer: (B) Lossless compression

Explanation:

 According to the question, the given technique is the example of the lossless compression. The lossless compression is one of the technique that decompress the data into the original data form without any type of losses.

The lossless compression is the technique that usually compress the data, text and the databases. This technique also improve the compression rate helps in reconstruct the original data. It is used in various types of encoding methods, GNU tool and zip file.

3 0
4 years ago
How can I identify what is and what isn't an IP Address?
adelina 88 [10]

Answer:

you can identify an ip address in the bar where u type links

Explanation:

7 0
3 years ago
Other questions:
  • Which type of denial of service attack exploits the existence of software flaws to disrupt a service?
    12·1 answer
  • The penalties for a person's third DUI conviction include fines of __________.
    11·2 answers
  • A ____ appears at the bottom of your e-mail messages and contains standard information about yourself that the recipient can use
    5·1 answer
  • You need to install an operating system on a computer that will be sharing files for the company employees. You estimate there w
    9·1 answer
  • If you do not specify any criteria in a delete query, Access will delete all the records in the table. Truth or False
    11·1 answer
  • What are horizontal and vertical page break? how and where are these inserted?​
    10·1 answer
  • Plz hurry it’s timed
    5·1 answer
  • Need answer ASAP. I’ll mark brainliest if correct
    7·1 answer
  • You will include code that will validate all user input. If the user inputs an invalid value, the program will respond with an e
    14·1 answer
  • Three types of query​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!