QuestionQuestion

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)

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.Scanner;

public class Container{

public static void main(String[] args){
Scanner in = new Scanner(System.in);

System.out.print("Please enter the volume of the cylinder or 0 to exit: ");
double volume = in.nextDouble();

System.out.print("Please enter the radius of the cylinder or 0 to exit: ");
double radius = in.nextDouble();

while (volume > 0 && radius > 0) {

double height = volume / (Math.PI * Math.pow(radius, 2));...

By purchasing this solution you'll be able to access the following files:
Solution.java.

$25.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats