Ask Java Expert


Home >> Java

 The use of standard Java input and output mechanisms

· The use of complex arithmetic expressions

· The use of modular design (methods)

· The use of one-dimensional arrays

As always, be sure to properly document your code. Consult the Java Coding Guidelines document for proper coding standards. Use good design principles and design the solution before attempting to write code.

Emptying a Water Tank

Water catchment systems are a critical source of water in many parts of the world. These systems collect rainwater and distribute it to a house, lodging, or neighborhood using a series of gravity-propelled plumbing. Such systems can also act as a reservoir by which local populations can "fill up" containers and transport the water to other locations.

Assume we have a full water catchment tank, shaped like a cylinder. How long would it take to empty that cylinder, if we "unscrewed" an output nozzle on the bottom? Determining the rate at which the cylinder would empty out would require knowledge of the height of the tank, the radius of the tank, and the radius of the output nozzle. Once we had this knowledge, we could apply a few simple math equations to get an approximate answer. This information would be helpful to measure the amount of water that would be used for various household uses (e.g. showers).

Exercise #1: Create a Java class called WaterTank.java. This program will simulate thedraining of a cylindrical water catchment tank. Your program will need to show how the rate at which water would exit the tank, assuming an output nozzle two inches (2") in diameter. Your inputs are as follows:

 

 

Variable

 

 

Meaning

 

 

Valid Range

 

 

 

 

height_of_tank

 

The height of the cylindrical tank, in inches

[72-240]

 

 

 

 

radius_of_tank

 

The radius of the cylindrical tank, in inches

[2-36]

 

 

 

Note that the values above will be input from the user only once. Both inputs are double values.

Once the input is finished, your program will display an output table with three columns: time (in seconds), volume lost, and fluid height (i.e. the height of the water in the cylindrical tank). Assuming a constant flow, the volume of water in the tank will decrease to zero over time (i.e. the tank will be empty). For example, a 36-inch high cylinder with a radius of 6 inches will produce the following table:

Intial Volume: 4071.50 cubic inches.

 

 

 

Time

Volume Lost

Fluid Height

====

===========

============

0

0.00

36.00

1

604.69

30.65

2

1115.97

20.79

3

1378.45

8.60

4

1182.06

-1.85

 

 

 

Note that the last value - and only the last value - for fluid height may be less than zero. Youshould assume the tank is initially full with water. Your table should compute one value for each second, starting at zero and ending when the tank runs dry (i.e. volume of fluid in the tank is ≤ 0).

The following constants and formulas will be helpful in your calculations (r = radius, h = height):

PI (π):

3.14159265

Initial Volume of a Cylinder (i.e. the water tank):

Velocity of Outward Flow Through the Nozzle:

Volume Lost From a Cylinder At Time t:

Height of Fluid in the Cylindrical Tank at Time t:

Note that you will first need to calculate the volume of the cylinder when it is full, and output it to the screen. For each time step, you will need to calculate the volume lost. Remember that the volume lost requires you to first calculate the velocity of flow. Once calculated, the volume lost is subtracted from that initial "full" volume. Afterwards, the new height of the fluid can be calculated from this new volume. When the volume in the tank reaches zero (or less), your program should stop its calculations. Your program may use the value of PI (π) shown here for testing purposes, or use the Math.PI constant.

Your numerical output should be precise to two decimal places on the right of the decimal for all real-number data. Your ability to modularize your solution is essential (i.e. break the program into methods). You must use arrays in your solution - at least two arrays are recommended to store the volume lost and fluid height values. Be sure to properly document your code and use good design principles

Java, Programming

  • Category:- Java
  • Reference No.:- M91312960
  • Price:- $40

Guranteed 36 Hours Delivery, In Price:- $40

Have any Question?


Related Questions in Java

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Applied software engineering assignment 1 -learning

Applied Software Engineering Assignment 1 - Learning outcomes - 1. Understand the notion of software engineering and why it is important. 2. Analyse the risk factors associated with phases of the software development lif ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As