Sign up to create your own snipts, or login.

Public snipts » achurod's snipts » Volume and Area Calculation Program

posted on Aug 15, 2009 at 8:32 p.m. EDT in 
  • def get_shape():
        print "Which do you want to calculate?"
        print "1    Area of Circle"
        print "2    Area of Trapezoid"
        print "3    Area of Triangle"
        print "4    Area of Rectangle"
        print "5    Surface Area of Cone"
        print "6    Surface Area of Cylinder"
        print "7    Surface Area of Pyramaid"
        print "8    Surface Area of Sphere"
        print "9    Volume of Cone"
        print "10   Volume of Cylinder"
        print "11   Volume of a Rectangular Prism"
        print "12   Volume of Pyramaid"
        print "13   Volume of Sphere"
        shape = int(raw_input("Choose the shape: "))
        return shape
    
    def get_choice():
        print "Select what you want to do"
        print "1    Calculate Area & Volume"
        print "2    Basic Calculator"
        print "3    Exit"
        print "4    Credits"
        choice = int(raw_input())
        return choice
    
    def get_selection():
        print "Select what you want to do."
        print "1 Calculate Area & Volume"
        print "2 Credits"
        print "3 Exit"
        selection = int(raw_input("Select what you want to do: "))
        return selection
       
    def main():
        print "Welcome to Volume. Area. Conversion. (VAC)"
        print "VAC is a free mathmatical program that calculates volume, area, surface area,converts lengths, and temperatures."
        print "VAC was created by Rodrigue Achu"
        choice = get_choice()
        if choice ==1:
            selection = get_selection()
            if selection ==1:
                shape = get_shape()
                if shape ==1:#Area of Circle
                    radius = input("Enter the radius: ")
                    area = 3.14*(radius**2)
                    print "The area is", area
                    main()
                elif shape ==2:#Area of Trapezoid
                    height = input ("Enter the height: ")
                    baseone = input ("Enter the first base: ")
                    basetwo = input ("Enter the second base: ")
                    area = (.5*height)*(baseone+basetwo)
                    print "The area is", area
                    main()
                elif shape ==3: #Area of Triangle
                    base = input("Enter the base: ")
                    height = input ("Enter the height: ")
                    area = base*height*.5
                    print "The area is", area
                    main()
                elif shape ==4:#Area of Rectangle
                    width = input ("Enter the width: ")
                    height = input ("Enter the height: ")
                    area = width*height
                    print "The area is", area
                    main()
                elif shape ==5:#Surface Area of Cone
                    radius = input ("Enter the radius: ")
                    length = input ("Enter the length: ")
                    pi = 22.0/7.0
                    surfacearea = (pi*radius*length)+(pi*radius**2)
                    print "The surface area is", surfacearea
                    main()
                elif shape ==6:#Surface Area of Cylinder
                    radius = input ("Enter the radius: ")
                    height = input ("Enter the height: ")
                    pi = 22.0/7.0
                    base = pi*radius*radius
                    lateralarea = 2*pi*radius*height
                    surfacearea = lateralarea + (base*2)
                    print "The surface area is", surfacearea
                    main()
                elif shape ==7:#Surface Area of Pyramaid
                    base = input ("Enter one side of the base: ")
                    height = input ("Enter the height: ")
                    sidelength = input ("Enter the side length: ")
                    surfacearea = (base*2*sidelength)+ (base**2)
                    print "The surface area is", surfacearea
                elif shape ==8:#Surface Area of Sphere
                    radius = input("Enter the radius: ")
                    pi = 22.0/7.0
                    surfacearea = (4*pi)*(radius**2)
                    print "The surface area is", surfacearea
                    main()
                elif shape ==9:#Volume of Cone
                    radius = input("Enter the radius: ")
                    height = input("Enter the height: ")
                    pi = 22.0/7.0
                    volume = (1/3)*pi*radius**2*height
                    print "The volume is", volume
                    main()
                elif shape ==10:#Volume of Cylinder
                    radius = input("Enter the radius: ")
                    height = input("Enter the height: ")
                    pi = 22.0/7.0
                    volume = height*pi*(radius**2)
                    print "The volume is", volume
                    main()
                elif shape ==11:#Volume of Rectangular Prism
                    length = input("Enter the length: ")
                    width = input("Enter the width: ")
                    height = input("Enter the height: ")
                    volume = length*width*height
                    print"The volume is", volume
                    main()
                elif shape ==12:#Volume of Pyramaid
                    height = input("Please enter the height: ")
                    base = input("Please enter one side of the base: ")
                    volume = (1/3)*(base**2)*(height)
                    main()
                elif shape ==13:#Volume of Sphere
                    radius = input("Please enter the radius: ")
                    pi = 22.0/7.0
                    volume = (4/3)*(pi)*(radius**3)
                    print "The volume is", volume
                    main()
            else:  # selection ==2
                print "VAC was made by RFA with help from Kdoiron, and several other people"
                main()
        if choice ==2:   # choice ==2
            def get_menu():
                print "Welcome to VAC's basic calculator"
                print "Enter the equation you wish to solve"
                print "Ex: 5+5, 5*5, 5/5, etc."
                print "Please note that to raise a power use **, for ex: 5**2 = 5*5 = 5^2"
                equation = input("Enter the equation you wish to solve: ")
                solution = equation*1
                print "the answer is", solution
                return solutioun
            get_menu()
        if choice ==3:    # choice == 3
            x = 20
            while x>= 1:
                print "VAC is now closing"
                x = x-1
    
        if choice ==4:
            print "VAC was made by RFA with help from Kdoiron, and several other people"
            main()
                               
    main()
    

    copy | embed

0 Comments

Sign up, or login to leave a comment.