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
cluponka [151]
3 years ago
7

Define a method calcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a d

ouble the volume of a pyramid with a rectangular base. calcPyramidVolume() calls the given calcBaseArea() method in the calculation. Relevant geometry equations: Volume
Computers and Technology
1 answer:
Rudik [331]3 years ago
6 0

Answer:

import java.io.*;

public class Main {

   public static void main(String[] args) throws IOException {

       double baseLength = 0, baseWidth = 0, pyramidHeight = 0;

       Object[] volume;

       volume = calcPyramidVolume(baseLength, baseWidth, pyramidHeight);

   }

   public static Object[] calcPyramidVolume(double baseLength, double baseWidth, double pyramidHeight) {

       double area = calcBaseArea(baseLength, baseWidth);

       double volume = baseLength * baseWidth * pyramidHeight;

       return new Object[]{volume, area};

   }

   public static double calcBaseArea(double length, double width) {

       return length * width;

   }

}

Explanation:

The problem is flawed because it is completely inefficient for one to create two separate methods to calculate the volume and the area when they can be done at once.

The second problem is that it was never specified whether to return something from the calcBaseArea method.

I assumed it required it, so it is not advisable to initiate the method as a double, but rather create it as an Object so that it can return two values: the volume and the area.

You might be interested in
Specialized programs that allow particular input or output devices to communicate with the rest of the computer system are calle
In-s [12.5K]
Hi!

These programs which allow a peripheral device to interact with the rest of the computer system are going to be <em>device drivers.</em>

Hopefully, this helps! =)
3 0
3 years ago
In this exercise you will debug the code which has been provided in the starter file. The code is intended to take two strings,
vampirchik [111]

Answer:

Here is the corrected program:

import java.util.Scanner; //to accept input from user

public class 02_14_Activity_one { //class name

    public static void main(String[] args) { //start of main method

    Scanner scan = new Scanner(System.in); //creates Scanner class object

  System.out.println("Enter first string"); //prompts user to enter first string

          String s1 = scan.nextLine(); //reads input string from user

  System.out.println("Enter second string"); //prompts user to enter second string

          String s2 = scan.nextLine(); //reads second input string from user

    System.out.println("Enter number of letters from each word"); //enter n

          int n = scan.nextInt(); //reads value of integer n from user

          System.out.println(s1.substring(0,n) + s2.substring(s2.length() - n ));

         } } //uses substring method to print a string made up of the first n letters of s1 and the last n letters of s2.

Explanation:

The errors were:

1.

Scanner scan = Scanner(System.in);

Here new keyword is missing to create object scan of Scanner class.

Corrected statement:

 Scanner scan = new Scanner(System.in);

2.

String s1 = nextLine();  

Here object scan is missing to call nextLine() method of class Scanner

Corrected statement:

String s1 = scan.nextLine();

3.

String s2 = Scanner.nextLine();

Here class is used instead of its object scan to access the method nextLine

Corrected statement:

String s2 = scan.nextLine();

4.

String n = scan.nextLine();

Here n is of type String but n is a whole number so it should be of type int. Also the method nextInt will be used to scan and accept an integer value

Corrected statement:

int n = scan.nextInt();

5.

System.out.println(s1.substring(1,n-1) + s2.substring(s1.length()-n));

This statement is also not correct

Corrected statement:

System.out.println(s1.substring(0,n) + s2.substring(s2.length() - n ));

This works as follows:

s1.substring(0,n) uses substring method to return a new string that is a substring of this s1. The substring begins at the 0th index of s1 and extends to the character at index n.

s2.substring(s2.length() - n ) uses substring method to return a new string that is a substring of this s2. The substring then uses length() method to get the length of s2 and subtracts integer n from it and thus returns the last n characters of s2.

The screenshot of program along with its output is attached.

7 0
3 years ago
in order for your photographs to be protected by copyright laws, you need to submit a written request​
andrew11 [14]

Answer:

The answer is "False".

Explanation:

The copyright law in the United States, namely the 1976 Copyright Law, was governed through the state constitution. The copyright constitution forbids an illegal copy of the work. Even so, it's also forbidden to obey the orders also-everyone can photocopy the ideas of work.

  • It doesn't cover single words, phrases, or slogans; common symbols.
  • It is typographical ornaments, logos, or coloring products or contents listings, that's why the given statement is false.
3 0
3 years ago
Which of the following is true about file formats?
statuscvo [17]

Answer:

A

Explanation:

The answer is A mate, if you need any help let me know please

3 0
3 years ago
Read 2 more answers
He said,'I am learning French these days' convert to indirect Speech​
Paha777 [63]

Answer:

Indirectl Speech:

He said that he is learning French these days•

4 0
3 years ago
Other questions:
  • Explain how you can compare the size of product to the size of a factor when multiplying fractions without actually doing the mu
    11·1 answer
  • How many bit does four gigabyte has
    8·2 answers
  • A network administrator wants to logically separate web servers on the network. Which of the following network device will need
    10·2 answers
  • hello my friend is doing a give away at 100 followers would you follow him for a chance to win 2000 vbucks his name is ZoVa_Velo
    15·2 answers
  • CHALLENGE ACTIVITY 3.7.2: Type casting: Reading and adding values.
    10·1 answer
  • Find a 95% confidence interval for the mean failure pressure for this type of roof panel.The article "Wind-Uplift Capacity of Re
    7·1 answer
  • In cell I5, enter a formula to calculate the total admission fees collected for the 2018
    5·2 answers
  • Why are new versions of applications packages released often ​
    9·1 answer
  • Plsss help me<br><br>1)give 2 examples of systems that you use or see in your day-to-day life​
    5·1 answer
  • You develop an app, and you don't want anyone to resell it or modify it. This is an example of: A an operating system. B open so
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!