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
Nonamiya [84]
3 years ago
11

k- Add the code to define a variable of type 'double', with the name 'cuboidVolume'. Calculate the volume of the cuboid and set

this variable value.

Computers and Technology
1 answer:
djverab [1.8K]3 years ago
7 0

Answer:

Here is the JAVA program to calculate volume of cuboid:

import java.util.Scanner; // Scanner class is used to take input from user

public class CuboidVol { // class to calculate volume of cuboid

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

Scanner input= new Scanner(System.in); //create Scanner class object

// prompts user to enter length of cuboid

System.out.println("Enter the cuboid length:");

double length=input.nextDouble(); //reads the input length value from user

// prompts user to enter width of cuboid

System.out.println("Enter the cuboid width:");

double width=input.nextDouble(); //reads the input width from user

// prompts user to enter height of cuboid

System.out.println("Enter the cuboid height:");

double height=input.nextDouble(); //reads the input height from user

/* the following formula is to calculate volume of a cuboid by multiplying its length width and height and a double type variable cuboidVolume is defined to store the value of the resultant volume to it */

double  cuboidVolume= length*width*height; //calculates cuboid volume

//displays volume of cuboid and result is displayed up to 2 decimal places

System.out.printf("Volume of the cuboid (length " + length + "/ height " + height + "/ width" +width +" is: " + "%.2f",cuboidVolume);   } }

Explanation:

The formula for the volume of a cuboid is as following:

Volume = Length × Width ×  Height

So in order to calculate the volume of cuboid three variable are required for length, width and height and one more variable cuboidVolume to hold the resultant volume of the cuboid.

The program is well explained in the comments added to each statement of the program. The program prompts the user to enter the value of height width and length of cuboid and the nextDouble() method is used to take the double type input values of height length and width. Then the program declares a double type variable cuboidVolume to hold the result of the volume of cuboid. Then the last printf statement is used to display the volume of cuboid in the format format "Volume of the cuboid (length  / height  / width ) is" and the result is displayed up to 2 decimal places.

The screenshot of the program along with its output is attached.

You might be interested in
Which of the following is an example of a fixed expense clothing or rent or entertainment or food
V125BC [204]
Salutations!

<span>Which is an example of fixed expense?

Rent is an example of fixed expense, It doesn't matter whether you sell a widget or produce thousand of them, you must still pay the rent in any </span><span>circumstances.
</span>
Hope I helped.
5 0
4 years ago
What does it mean for a computing system to have an interface? A. An interface is a conduit through which the user can interact
Wittaler [7]

Answer:

An interface device (IDF) is a hardware component or system of components that allows a human being to interact with a computer, a telephone system, ...

Explanation:

5 0
1 year ago
1. What is the connection between a credit report and a credit score?
viktelen [127]

Answer:

<em>Credit report: A credit report is a record of a consumer's credit history and serves as credit references. Credit score: A credit score is an algorithm that measures your credit risk based on the information in your credit report at one point in time.</em>

Hope this helps!!

5 0
3 years ago
Write a program that prompts the user to enter a positive integer and displays all its smallest factors in decreasing order.
user100 [1]

Answer:

<fact>[ZRjKt9sw6V(gh6E)ehNM3]<zip>

Explanation:

8 0
3 years ago
-1
N76 [4]

Answer:A flowchart is a diagram that depicts the steps involved in solving a problem. The following flowchart shows how to output the multiplication table ( n * 1 to m * 1) of a number, n and m:

3 0
3 years ago
Other questions:
  • Convert 1 pound into newtons
    8·2 answers
  • PHOTOSHOP QUESTION:
    14·1 answer
  • Help me 28pts to anyone who answer this
    5·2 answers
  • During which part of geologic time were dinosaurs most common?
    11·2 answers
  • What is wrong with the formula below?<br><br> SUM(A1:A5)/SUM(B1:B5)
    7·1 answer
  • Once a table is inserted into a publication, which two tabs become available?
    5·1 answer
  • 1⁰=?<br> Is equal to...........
    12·2 answers
  • A) Suppose a computer has an instruction pipeline with 4 phases. How many cycles (if there are no delays) would it take to compl
    13·1 answer
  • Why is the term RAW image file generally used to describe a variety of file formats, which are sometimes known as digital raw ca
    13·1 answer
  • 1.Which thematic group uses technology to direct the behavior of dynamical systems, ensuring that they behave in a predictable m
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!