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
hjlf
3 years ago
11

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 = base area x height x 1/3Base 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;}}

Computers and Technology
2 answers:
soldi70 [24.7K]3 years ago
7 0

Answer:

public class CalcPyramidVolume {

public static void main(String[] args) {

 // Test the method pyramidVolume() by printing out a test case

               // result.

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

 return;

}

// Method name is pyramidVolume()

// It receives three parameters of type double - baseLength,

// baseWidth, and  baseHeight;

// It returns the calculated volume (which is of type double) of the

// pyramid  using the appropriate formula.

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

 // From the parameters given, calculate the base area of the

              // pyramid first.

 double baseArea = baseLength * baseWidth;

 // From the base area, calculate the volume of the pyramid.

 // Note the use of 1 / 3.0 rather than 1 / 3. This is to bypass the

 // integer  division of 1/3 which will give zero(0).

 double volume = baseArea * baseHeight * 1 / 3.0;

 // Return the calculated volume

 return volume;

}

}

Explanation:

There are two versions to this code. The first one allows the user to enter the values for the length, width and height of the pyramid. The second version uses preset values for the length, breadth and height of the pyramid. The second version is represented in the answer above.

The source code files for the two versions have been attached to this response. Kindly download the files and go through the codes especially the comments. Every segment of the codes contains explanatory comments. Carefully go through these comments for explanation of the codes.

Hope this helps!

Download java
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
<span class="sg-text sg-text--link sg-text--bold sg-text--link-disabled sg-text--blue-dark"> java </span>
Vinil7 [7]3 years ago
4 0

Answer:

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

  double Volume,baseArea;

  baseArea = baseLength * baseWidth;

  Volume = baseArea * pyramidHeight * 1/3;

  return Volume;

}

Explanation:

You might be interested in
The variable used in a loop to control the number of times it is executed is called a _______.
tia_tia [17]

Answer:

the variable used in a loop to control the number of timer is executed is called a interaction.

Explanation:

a particular way in which matter, fields, and atomic and subatomic particles affect one another

6 0
3 years ago
Write c++ program to find maximum number for three variables using statement ?​
pantera1 [17]

Answer:

#include<iostream>

using namespace std;

int main(){

int n1, n2, n3;

cout<<"Enter any three numbers: ";

cin>>n1>>n2>>n3;

if(n1>=n2 && n1>=n3){

cout<<n1<<" is the maximum";}

else if(n2>=n1 && n2>=n3){

cout<<n2<<" is the maximum";}

else{

cout<<n3<<" is the maximum";}

return 0;

}

Explanation:

The program is written in C++ and to write this program, I assumed the three variables are integers. You can change from integer to double or float, if you wish.

This line declares n1, n2 and n3 as integers

int n1, n2, n3;

This line prompts user for three numbers

cout<<"Enter any three numbers: ";

This line gets user input for the three numbers

cin>>n1>>n2>>n3;

This if condition checks if n1 is the maximum and prints n1 as the maximum, if true

<em>if(n1>=n2 && n1>=n3){</em>

<em>cout<<n1<<" is the maximum";}</em>

This else if condition checks if n2 is the maximum and prints n2 as the maximum, if true

<em>else if(n2>=n1 && n2>=n3){</em>

<em>cout<<n2<<" is the maximum";}</em>

If the above conditions are false, then n3 is the maximum and this condition prints n3 as the maximum

<em>else{</em>

<em>cout<<n3<<" is the maximum";}</em>

return 0;

3 0
3 years ago
A. True
Ksivusya [100]
True 
You can only do it ascending because you will get confused 
7 0
3 years ago
1) differentiate between Tittle and caption
Yakvenalex [24]

Answer:

The difference and the steps to insert media in the project can be defined as follows:

Explanation:

Title:

The title is a document, that defines the object that is legally operated.  

Caption:

The Caption is also known as the title or the heading, which described the words on a screen, that conveys the message, that is being said.

Difference:

  • The titles will be assigned to the starting of the clip,  that selects, and charges will be applied to the project at the end.  
  • The caption may also be applied as a text to a specific clip for the reason.

Step to insert any media in the project:

  • Choose the preferred location to insert your media.  
  • Tap on the top of the insert Tab.      
  • Choose the desired media form.  
  • after selecting your desired media, click on the insert button, at this, the media will be inserted.
3 0
3 years ago
Which tool did Adnan use to modify the image?
artcher [175]

Answer:

D

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • What kind of testing is basically checking whether a game or feature works as expected by the developers?
    10·1 answer
  • Juliet is trying to increase her savings account and she decides that she is going save an additional $700 every month. If her m
    9·1 answer
  • To increase the view of a document on the screen, use the _____. View icon Zoom slider full-screen reading boldface font
    9·1 answer
  • Software as a Service (SaaS) refers to the use of computing resources, including software and data storage, on the Internet rath
    13·1 answer
  • Many businesses use robotic solutions. Which department of the food and beverage industry uses robotic solutions on a large scal
    10·2 answers
  • Which software is primarily used to create
    15·2 answers
  • What does a page break do?
    13·1 answer
  • What is Celeste? ( This is for my coding class )
    6·2 answers
  • Rtjfifjjir<br> jhjjbkjkjjgggjhvhjvhf
    9·1 answer
  • Calcula l'energia (Kwh) consumida per una màquina de 30 CV que funciona durant 2 hores.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!