# Cone Volume and Surface Area Calculator # import math punctuation ='.' def is_nneg_float(s): i=s.find('.') if i==-1 and s.isdigit(): return True else: if s[0:i].isdigit() and s[i+1].isdigit(): return True else: return False def get_nneg_float(p): while True: s=input(p) if is_nneg_float(s)==True: break else: print("invalid input") continue return float(s) print("This program finds the cone surface area and the cone") print("volume when given the radius and height of the cone.") print("="*50) def cone_surface_area(r_float,h_float): return((math.pi)*(r_float**2) + (math.pi)*(r_float)*(math.sqrt((r_float**2)+(h_float**2)))) def cone_volume(r_float,h_float): return(((math.pi)*(r_float**2)*h_float)/3) r_float = get_nneg_float(("Please input an integer for the radius ")) print("="*50) h_float = get_nneg_float(("Please input an integer for the height ")) print("="*50) c_s_a = round(cone_surface_area(r_float,h_float),2) c_v = round(cone_volume(r_float,h_float),2) print("Cone radius is :", r_float,"ft") print("Cone height is :", h_float,"ft") print("Cone Suface Area is equal to:",c_s_a,"ft^2") print("Cone Volume is equal to:",c_v,"ft^3")