Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

ONLY jGRASP B01: Weight of water in a fish bowl The user has a rectangle fish bo

ID: 3895524 • Letter: O

Question

ONLY jGRASP

B01: Weight of water in a fish bowl The user has a rectangle fish bowl with a solid cyli the height of the fish bowl. nder in the middle, as displayed in the image attached. The height of the cylinder is the same as r- Radius of cylinder h - Height of fish bow d- Deuth f fish bowl w- Width of fish bowl Write a program that will ask the user for the width, height and depth of the fish bowl, as well as the radius of the solid cylinder. These will be introduced as inches and your program needs to convert them to meters (1 inch 0.0254 meters) Then, you need to compute the volume of the fish bowl that can be filled with water (volume of fish bowl - volume of the solid cylinder) in cubic meters. After you know how much water can be filled with water, your program needs to compute and display how much will that amount of water weigh (assume 1 cubic meter of water 1,000 kg). Display the weight in pounds (1 pound 1/2.2046 kg). B02 Changing the text entered by the user : ? e the user will always enter a lowercase letter other than 'z). Each time the user Write a program that asks the user to enter 3 letters (let's ass 02

Explanation / Answer

Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you

import java.util.Scanner;

public class FishBowl {
public static void main(String[] args) {
double width, depth, height, radius;
Scanner keyboard = new Scanner(System.in);

System.out.print("Enter width of fish bowl (inches): ");
width = keyboard.nextDouble();

System.out.print("Enter depth of fish bowl (inches): ");
depth = keyboard.nextDouble();

System.out.print("Enter height of fish bowl (inches): ");
height = keyboard.nextDouble();

System.out.print("Enter radius of cylinder (inches): ");
radius = keyboard.nextDouble();


double INCH_TO_METERS = 0.0254; //1 inch = 0.0254 m
double KG_TO_POUND = 2.2046; //1 Kg = 2.2046 pounds


//convert all to meter
width = width * INCH_TO_METERS;
height = height * INCH_TO_METERS;
depth = depth * INCH_TO_METERS;
radius = radius * INCH_TO_METERS;


double volumeBowl = width * depth * height;
double volumeCylinder = 3.14159 * radius * radius * height;
double volumeWater = volumeBowl - volumeCylinder; //cubic meter or kg since 1 cubic m = 1 kg
double waterPounds = volumeWater * KG_TO_POUND;

System.out.printf("Volume of bowl is %.2f cubic meter ", volumeBowl);
System.out.printf("Volume of cylinder is %.2f cubic meter ", volumeCylinder);
System.out.printf("The weight of water in kgs is %.2f ", volumeWater);
System.out.printf("The weight of water in pounds is %.2f ", waterPounds);
}
}


output
======
Enter width of fish bowl (inches): 40
Enter depth of fish bowl (inches): 15
Enter height of fish bowl (inches): 15
Enter radius of cylinder (inches): 3
Volume of bowl is 0.15 cubic meter
Volume of cylinder is 0.01 cubic meter
The weight of water in kgs is 0.14
The weight of water in pounds is 0.31