Asked Feb 16, 2019

note which line the user inputs and presses enter
• area = radius * radius * pi
• volume = area * length
Sample Run:
Enter the radius and length of a cylinder: 5.5 12
The area is 95.0331
The volume is 1140.4


Expert Answer

Step 1

The algorithm for the program would be as below:

  1. Declare 4 float variables for accepting user input and computing the output
  2. Declare a static constant float variable to hold the constant value of Pi
  3. Prompt the user for the input
  4. Accept the user input into floating point data types
  5. Compute the area and volume using formula given and assign them to float variables
  6. Print the value of area and volume as required.

We use the Scanner class from the util package of java to accept user input.

Step 2

The java program is given below:

import java.util.*;

public class CylinderCalculator{

            private static final float PI = 3.14159f;

            public static void main(String[] args) {

                        float radius,length;

                        float area, volume;

                        Scanner reader = new Scanner(;

                        System.out.println("Enter the radius and length of a cylinder:");


Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in


Computer Engineering


Related Computer Engineering Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: how can I create comments in python?

A: In python, # character is used to start the single line comments. Place a hash symbol in front of a ...


Q: Imagine you’d like a contractor to build a software application for you that operates like Windows C...

A: Statement of objectives (SOO):It provides an overall objective which serves as the basis for the sta...


Q: rewrite the function F = (A ⊕ B) ⊕ C without the XOR operator, ⊕.

A: The XOR operator is defined as 1 ⊕ 1 = 0, 1 ⊕ 0 = 1, 0 ⊕ 1 = 1, and 0 ⊕ 0 = 0. As the output is true...


Q: A sequential circuit has an input (X) and two outputs (S and V). X represents a 4-bit binary number ...

A: Solution:The following code is described about the behavioral Verilog description for given state gr...


Q: Based on Program.Py below, develop a list of requirements that could have been used to create the or...

A: Requirements are statements or items that shall be used or that a system needs while writing a progr...


Q: 1. What is the output of the following code? (A)for (int i = 1; i < 4; i++) {System.out.println("...

A: Since multiple questions have been asked and it is not clear which one question you want to be answe...


Q: Consider different risk mitigation strategies for system development programs. What type of strategy...

A: Risk mitigation: Let’s start to discuss about the risk . Risk is a possibility of loss which occurre...


Q: Write a program called StudentTable that prints the below table. Use only print() orprintf(). DO NOT...

A: The program in Java would be using print and printf statements with formatting for left alignment of...


Q: how do you known when you need to use int and float? I know that int refers to intergers and float r...

A: “input” keyword in Python:In Python, the function which is used to read the input from the keyboard ...