Six Step of Software Development
# Six steps of software development
### STEP ONE ###
# Problem Analysis
#
# Problem:
# Create a program that determines the value of an investment after 10 years.
# Knowns:
# Money put in a bank earns interest.
# Interest accumulates as years pass.
# Formula for calculating the value of one year is I = P*1+rt
# I = interest (the calculated amount after a year)
# P = principal (money put into the bank)
# rt = rate (yearly)
### STEP TWO ###
# Specification (what do we need?)
#
# Input:
# principal - the amount of money being invested.
# APR - the annual percentage rate expressed as a decimal number (float).
# Output:
# Value of investment 10 years into the future.
# Relationship:
# Value after one year is principal*(1+apr). Apply formula 10 times.
### STEP THREE ###
# Design (write it using pseudo code)
#
# defining the function:
# print introduction
# input amount of the principal (principal)
# input amount of percentage rate (apr)
# repeat 10 times:
# principal = principal * (1 + apr)
# print the value of principal
### STEP FOUR ###
# Implementation (code it)
def main():
print('This program calculates the future value',\
'of an investment.')
principal = float(input('Enter the initial principal: '))
apr = float(input('Enter the anual interest rate: ' ))
investment = float(input('Enter how much you will invest each year: '))
period = int(input('Enter amount of years you would like to calculate for: '))
if period == 1:
years = 'year'
else:
years = 'years'
for i in range(period):
principal = (principal+investment) * (1 + apr)
print('The value in', period, years, 'is:', principal)
if __name__ == "__main__":
main()
### STEP FIVE ###
# Testing and debugging
#
# Bug testing:
# What if user inputs a letter?
# What if the user inputs python code (code injection)?
# What if user inputs a number with %?
# try, except and if/else statements to fix that.
# User interface:
# Describe input better, so the user doesn't mess it up
# Expect that the user will mess up however, and work around that.
### STEP SIX ###
# Maintenance
#
# Continue to maintain and develop the software until it dies or becomes irrelevant.