# For any of these, you could put them into a function def, but you
# certainly don't have to do so.

# ----------------------------------------------------------------------

#  (Programming: 8 points) A triangle with sides of length
#   A, B, and C, where C is the longest side, is a right triangle if
#         A**2 + B**2 = C**2
# Write code you could put into file isRightTriangle.py to accept
# from the user 3 floats A, B, and C.  First check that C is the largest
# of the three; print an error message if not and stop.  If C is
# largest, check if the triangle is a right triangle.  Since the sides
# are floats and float arithmetic is approximate, check that
#       -0.0000001 < (A**2 + B**2 - C**2) < 0.0000001$
# Report the results.  You can assume any modules you need have been
# imported. Follow the samples below:
# 
# > python isRightTriangle.py     > python isRightTriangle.py
# Enter A: 3.0                    Enter A: 4.0
# Enter B: 5.0                    Enter B: 4.0
# Enter C: 4.0                    Enter C: 5.0
# C must be largest side          Not right triangle
# > python isRightTriangle.py     > python isRightTriangle.py
# Enter A: 3                      Enter A: 1.0
# Enter B: 4                      Enter B: 1.0
# Enter C: 5                      Enter C: 1.4142135623730951 # sqrt(2)
# Right triangle                  Right triangle

A = float( input( "Enter A: " ))
B = float( input( "Enter B: " ))
C = float( input( "Enter C: " ))
if not (C > A and C > B):
    print("C must be largest side")
elif (-0.0000001 < (A**2 + B**2 - C**2) < 0.0000001):
    print("Right triangle")
else:
    print("Not right triangle")

# ----------------------------------------------------------------------

# (Programming: 8 points) A certain company has decided to
#   give all employees a bonus.  Write code you could put in file 
#     bonus.py to compute and print the bonus. Accept from the user two
#   floats: annual salary and years of service.  The bonus is a
#   percentage of annual salary based on an employee's years of service
#   as follows: more than 10 years of service, bonus is 10%; 6 to 10
#   years of service, bonus is 8%; less than 6 years of service, bonus
#   is 4%.  Assume inputs are non-negative floats.  Show the bonus with
#   a dollar sign and two digits after the decimal point.
#
# Below is some sample behavior:
# > python bonus.py                  > python bonus.py
# Salary: 100000.0                   Salary: 50500.00
# Years of service: 7.8              Years of service: 15
# Bonus is: $8000.00                 Bonus is: $5050.00

salary = float( input("Salary: "))
yearsService = float( input("Years of service: "))
if yearsService > 10:
    multiplier = 0.10
elif 6 <= yearsService <= 10:
    multiplier = 0.08
else:
    multiplier = 0.04
bonus = salary * multiplier
print("Bonus is: $", format(bonus, ".2f"), sep="")

# ----------------------------------------------------------------------

# (Programming: 8 points) A triangle is equilateral if
#   all three sides are of equal length.  It's isosceles if
#   exactly two sides are equal.  It's scalene if no two sides are
#   equal.  Write code you could put into file triangleType.py to
#   check the type of a triangle, based on the sides.  Accept from the
#   user 3 floats A, B, and C.  Check that all are positive; if not,
#   print an error message and stop.  If so, check and report whether
#   the triangle is equilateral, isosceles, or scalene.  See the samples
#   below.
#
# > python triangleType.py
# Side A: -3
# Side B: 2.7
# Side C: 9
# Sides must be positive
# > python triangleType.py
# Side A: 5
# Side B: 5.0
# Side C: 5
# Triangle is equilateral
# > python triangleType.py
# Side A: 2.5
# Side B: 8
# Side C: 2.5
# Triangle is isosceles
# > python triangleType.py
# Side A: 2.3
# Side B: 2.5
# Side C: 2.7
# Triangle is scalene

A = float( input( "Side A: " ))
B = float( input( "Side B: " ))
C = float( input( "Side C: " ))
if (A <= 0 or B <= 0 or C <= 0):
    print( "Sides must be positive" )
elif (A == B == C):
    print( "Triangle is equilateral" )
elif (A == B or B == C or A == C):
    print( "Triangle is isosceles" )
else:
    print( "Triangle is scalene" )

#  (Programming: 8 points) A utility company charges based
#   on the number of units a customer uses in a month.  For the first
#   100 units there is no charge; the next 100 units cost $0.05 per
#   unit; for usage above 200 units, the cost is $0.10 per unit.  Write
#   code you could put into file utilityBill.py that does the
#   following: accept from the user an integer number of units, compute
#   and report the total bill.  Show the bill with dollar sign and two
#   digits after the decimal point. Assume the input is an integer, but
#   print an error if it's negative.  Some sample behavior is below:
#
# > python utilityBill.py
# Report usage units: -17
# Negative value entered.
# > python utilityBill.py
# Report usage units: 99
# You pay: $0.00
# > python utilityBill.py
# Report usage units: 155
# You pay: $2.75
# > python utilityBill.py
# Report usage units: 275
# You pay: $12.50
# > python utilityBill.py
# Report usage units: 1000
# You pay: $85.00

units = int( input( "Report usage units: " ))
if units < 0:
    print( "Negative value entered." )
else:
    if units <= 100:
        cost = 0.0
    elif 100 < units <= 200:
        cost = 0.05 * (units - 100)
    else:
        cost = 100 * 0.05 + (units - 200) * 0.10
    print( "You pay: $", format( cost, ".2f" ), sep = "")

    
