#02 The Gardening Company

Go Back

Flowchart


Pseudocode

SUBROUTINE calc() INPUT radius "Enter the radius" INPUT height "Enter the height" INPUT cost "Enter the cost" area=3.14159*radius*radius volume=area*height total=volume*cost_per_cm PRINT The total cost is: %.2f'%total RETURN total calc()

Code

def get_total(): #run this code until the try loop is finished while True: try: radius=float(input('Enter the radius:\n')) height=float(input('Enter the height:\n')) cost_per_cm=float(input('Enter the cost:\n')) #break the loop when they have been entered break #this is an error text for if nothing is inputed into the radius, height and cost_per_cm except: print('an error occoured, please try again') #these are calculations made to get the final total area=3.14159*radius*radius volume=area*height total=volume*cost_per_cm #print out the total cost print('The total cost is: %.2f'%total) return total #call the function get_total()

To run code