Project 2: Water Well Write a program called WaterWell. Many private water wells
ID: 3915887 • Letter: P
Question
Project 2: Water Well Write a program called WaterWell. Many private water wells produce only 1 or 2 gallons of water per minute. One way to avoid running out of water with these low-yield wells is to use a holding tank. A family of 4 will use about 250 gallons of water per day. However, there is a "natural" water holding tank in the casing (i.e. the hole) of the well itself The deeper the well, the more water that will be stored that can be pumped out for household use. But how much water will be available? Write a program that allows the user to input the radius of the well casing in inches (a typical well will have a 3 inch radius) and the depth of the well in feet (assume water will fill this entire depth, although in practice that will not be true since the static water level will generally be 50 feet or more below the ground surface). The program should output the number of gallons stored in the well casing. For your reference: ?r2h where r is the radius and h is the height. The volume of a cylinder is T 3.1415 1 cubic foot 7.48 gallons of water · For example, a 300 foot well full of water with a radius of 3 inches for the casing holds about 441 gallons of water - plenty for a family of 4 and no need to install a separate holding tank. For example, the dialogue should be: This program calculates how much water will be 'available in a well. What is the radius of the casing in inches? 10 What is the depth of the well in feet? 10 The well contains 163.18347222222226 gallons Program successfully ended Please run the program again to do another calculation.Explanation / Answer
import java.util.*;
class WaterWell
{
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("This program calculates how much water will be available in a well.");
System.out.println(" What is the radius of the casing in inches? ");
double radius = input.nextDouble();
radius = radius/12; // convert radius in inches to feet
System.out.println("What is the depth of the well in feet? ");
int height = input.nextInt();
double volume = 3.1415*radius*radius*height;// compute volume
double gallonsOfWater = volume *7.48;
System.out.println("The well contains "+ gallonsOfWater +" gallons");
System.out.println("Program successfully ended.");
System.out.println("Please run the program again to do another calculation");
}
}
Output:
This program calculates how much water will be available in a well.
What is the radius of the casing in inches? 10
What is the depth of the well in feet? 10
The well contains 163.18347222222226 gallons
Program successfully ended.
Please run the program again to do another calculation
Do ask if any doubt. Please upvote.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.