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

$38.00

or $1 if you
register a new account!

Related Homework Solutions

Money Problems in Java
Homework Solution
$20.00
Java
Programming
Codes
Algorithms
Money
Dimes
Nickels
Pennies
Input
Output
Integers
Statements
Variables
Accounting
Recursion Methods
Finance
Railroads Problem
Homework Solution
$100.00
Java Programming
Computer Science
Graph
Input
Arrival
Output
Railroad
Scenario
Location
Java Programming: User Defined Company
Homework Solution
$40.00
Java
Programming
Computer Science
Company
Stock Symbol
Stock Value
Constructor
Methods
Strings
Variables
Business
Finance
Economy
Hardware
Software
Arrays
Lists
Java Program And UML Diagram For Divers
Homework Solution
$20.00
Java
Programming
Computer Science
Coding
Divers
Testers
UML Diagram
Methods
Loops
Statements
Average Scores
Variables
Input Files
Output Files
Contest
Winner
Records
Data Sets
Array Problems in Java: Summation, Average, Min/Max, Searching, Sorting
Homework Solution
$13.00
Java
Programming
Coding
Computer Science
Arrays
Summation
Average
Minimum Number
Maximum Number
Bubble Sort
Selection Sort
Sequential Search
Binary Search
Algorithms
Input
Output
Methods
Integers
Functions
Get help from a qualified tutor
Live Chats