# Ryan Martin
# macid: abcd123
# student number: #######
# July 12, 2011
#
# This is a solution for Major Assignment 1 (Lab 04) Version 08.

import math

print """\

This program is a solution to Major Assignment 1 (Lab 04) Version 08.

"""

#INPUTS
V = input("Enter a value for the voltage, V: ")
R = input("Enter a value for the resistance, R: ")
C = input("Enter a value for the capacitance, C: ")
t = input("Enter a value for the elapsed time, t: ")
print 

#CALCULATION
A = ( float(V) / R ) * ( 1 - math.exp( - float(t) / ( R * C) ) )
B = ( float(V) / R ) * ( 1 - math.exp( -2 * float(t) / ( R * C) ) )
C = 100.0 * abs((A - B) / B)

#OUTPUT
print "The current for V, R, C, and t =", A
print "The current for V, R, C, and 2t =", B
print "The relative difference between these values =", C
print ""


'''
Design Question

If t, R and C are left as integer values, there will be a
loss of precision in the expression -t / (R * C) due to
integer division. 
Similarily, if V and R are both integers, V / R will also
result in a loss of precision.
It is necessary to convert these values to floats
so that the calculation is correct..

Test Plan

Test: 1
Input: [120,5,4e-6,2e-5]
Expected Output: [15.1708934119,20.7519532023,26.894142137]

Test: 2
Input: [90.5,3.5,5.4e-7,1.8e-6]
Expected Output: [15.8809062091,22.0080981964,27.8406245]

Test: 3
Input: [string,3.5,5.4e-7,1.8e-6]
Expected Output: [error - NameError]

Test: 4
Input: [90.5,0.0,5.4e-7,1.8e-6]
Expected Output: [error - ZeroDivisionError]
'''
