Water Overflow Java
PROGRAM TO CHECK IF TANK WILL OVERFLOW, UNDERFLOW OR FILLED IN GIVEN TIME
OUTPUT:
Underflow
class Number{ // function to calculate the volume of tank public static float volume(int radius, int height) { return ((22 / 7) * radius * radius * height); } // function to print overflow / filled / // underflow accordingly public static void check_and_print(double required_time, double given_time) { if (required_time < given_time) System.out.print( "Overflow" ); else if (required_time > given_time) System.out.print( "Underflow" ); else System.out.print( "Filled" ); } // driver code public static void main(String[] args) { int radius = 5, // radius of the tank height = 10, // height of the tank rate_of_flow = 10; // rate of flow of water double given_time = 70.0; // time given // calculate the required time double required_time = volume(radius, height) / rate_of_flow; // printing the result check_and_print(required_time, given_time); }}
Underflow
Comments
Post a Comment