# Lab3_CubeSum.py
#
# Task in lab 3 to write a program that calculates the sum of the cube roots
# of the first n numbers, where n is input by the user
#
# J Cardell, Feb 10, 2011

# If you use the line "import math" then you need to use the "math." notation
# with the math library functions. We will discuss this notation more with
# chapter 5
from math import *

def main():
    n = input("Enter an integer: ")

    # Initialize accumulator variable
    cSum = 0

    # Calculate the cube root and add the value into the accumulator variable
    for j in range (1, n+1):
        # use of "1/3.0" ensures the exponent is in floating point notation.
        cSum = cSum + pow(j,1/3.0)

    print "The sum of the cube roots of the first", n, "numbers is", cSum
    
    # format the number to have only 2 decimal places
    cSum2 = round(cSum, 2)
    print "The sum of the cube roots of the first", n, "numbers is", cSum2


main()

