# Ryan Martin
# macid: abcd123
# student number: #######
# July 12, 2011
#
# This is a solution for Marked Assignment 1 (Lab 03) on Thursday.

import math

def main():

    print """\

This program is a solution to Marked Assignment 1 (Lab 03) on Thursday.

"""

    #INPUTS
    f = input("Enter a value for the observed frequency, f: ")
    T = input("Enter a value for the object's temperature, T: ")
    print 
    
    SPEEDOFLIGHT = 3e8
    PLANCKCONSTANT = 6.63e-34
    BOLTZMANNCONSTANT = 1.38e-23

    #CALCULATION
    A = ( 2 * PLANCKCONSTANT * f**3 ) / ( SPEEDOFLIGHT**2 * ( math.exp(( PLANCKCONSTANT * f ) / ( BOLTZMANNCONSTANT * T ))  - 1 ) )
    B = ( 2 * PLANCKCONSTANT * f**3 ) / ( SPEEDOFLIGHT**2 * ( math.exp(( PLANCKCONSTANT * f ) / ( BOLTZMANNCONSTANT * 2 * T ))  - 1 ) )
    C = 100.0 * abs((A - B) / B)

    #OUTPUT
    
    print "The intensity for f and T, A=", A
    print "The intensity for f and 2T, B=", B
    print "The relative difference between these values, C=", C
    print ""

main()


##Design Question
##
##In this case, since both planck's constant (h) and boltzmann's constant (k) are 
##being stored as floats, it is not necessary for f and T to be floats themselves,
##since any integer multiplied by a float will be "converted" to a float for the 
##calculation. However, if h, k, f and T were all integers, then there would be a 
##loss of precision in the statement (h*f)/(k*T) due to integer division.
##
##Testing Report
##
##Test: 1
##Input: [5.05e14,5000]
##Expected Output: [1.49352809211e-08,1.83939201483e-07,91.880316539]
##Actual Output: [1.49352809211e-08,1.83939201483e-07,91.880316539]
##Result: Pass
##
##Test: 2
##Input: [string,4500.25]
##Expected Output: [error]
##Actual Output: [NameError]
##Result: Pass
##
##Test: 3
##Input: [5.05e14,0]
##Expected Output: [error]
##Actual Output: [ZeroDivisionError]
##Result: Pass

