Question

Suppose that your work for a beverage company. The Company wants to know the optimal cost for a cylindrical container that holds a specified volume. Write a fragment of code that uses and ask-before-iteration loop. During each iteration of the loop, your code will ask the user to enter the volume and the radius of the cylinder. Compute and display the height and cost of the container. Use the following formulas, where V is the volume, r is the radius, h is the height, and C is the cost.
h = V/(π * r * r)
C = 2πr(r + h)
Convert the resource code for this program to a class and develop a demo class to test the class.

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Container{

private double volume;
private double radius;

public Container() {
volume = 0.0;
radius = 0.0;
}

public void setVolume(double volume) {
this.volume = volume;
}

public double getVolume() {
return volume;
}

public void setRadius(double radius) {
this.radius = radius;
}

public double getRadius() {
return radius;
}...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Java Program For Vending Machine
Homework Solution
$40.00
Java
Programming
Computer Science
Vending Machine
Drinks
Password
Screen
Inventory
Menu
Errors
Money
ChatBot Using Java Programming
Homework Solution
$7.00
Java
Programming
Coding
Chatting
Bot
Users
Computers
Sentences
Symbols
Instant Messaging
Input
Output
Special Characters
Even Numbers
Odd Numbers
Java Program: Strings, Integers, Statements
Homework Solution
$20.00
Java
Programming
Coding
Computer Science
Integers
Statements
Strings
Special Characters
Error Messages
Lines
Input
Output
Variables
Operators
Java Problems: Euclidean Distance and Arrays
Homework Solution
$20.00
Java
Programming
Computer Science
Coding
Euclidean Distance
Reversing an Array
String Values
Integer Values
Boolean Arrays
Input
Output
Square Root
Sum of Squares
Mathematics
Vectors
Rows
Columns
Personal Name List in Java
Homework Solution
$8.00
Java
Programming
Computer Science
Codes
Algorithms
Personal Name List
Records
Errors
Arrays
Items
Variables
Statements
Characters
Moving Elements
Input
Output
Get help from a qualified tutor
Live Chats