/*******************************************************************************
Problem: Analyze a program in which a Bank has a rate of return on the
investment as 5%. Get the name of the customer, initial investment amount
from the user. Calculate the final amount for 1 year. Display the name of
the customer, initial invested amount, and investment earnings
and the final amount.
********************************************************************************/
/*******************************************************************************
Analysis
Input:
Given:
- investment return rate = 0.05 - const Real
User:
- customer name - variable String
- initial investment - variable Real
Processing:
- Calculate investment earnings = initial investment * investment return rate
- Calculate final amount = investment earnings + initial investment
Output:
- customer name
- initial investments
- investment earnings
- final amount
******************************************************************************/
/******************************************************************************
Design = Pseudo Code
******************************************************************************/
//Constant Declarations
Constant Real INVESTMENT_RETURN_RATE = 0.05 // this is the 5% return of interest
Module main ()
//Declarations - variables
Declare String customerName = ""
Declare Real initInvestment = 0.0
Declare Real investmentEarnings = 0.0
Declare Real finalAmount = 0.0
//Input
Set customerName = Call getString("Enter your name: ")
Set initInvestment = Call getReal("Enter your Initial Investment: ")
//Processing
Set investmentEarnings = call calcInitInvestment(initInvestment)
Set finalAmount = calcFinalAmmout(initInvestment, investmentEarnings)
//Output
Call output(customerName, initInvestment, investmentEarnings, finalAmount)
End module
//Rest of the functions and modules are created here
Function String getString(String prompt)
Declare String nString = "" //local variable to hold input
Display prompt
Input nString
Return nString
End Function // end getString
Function Real getReal(String prompt)
Declare Real nReal = 0.0 // local variable to hold the input
Display prompt
Input nReal
Return nReal
End Function // end getReal
Function Real calcReturn(Real nInitInvestment)
Declare Real nEarnings = 0.0 // holds the answer
Set nEarnings = nInitInvestment * INVESTMENT_RETURN_RATE
Return nEarnings
End Function //End calcReturn
Function Real calcTotal(Real nInvestmentEarning, Real nInitInvestment)
Declare Real nFinalAmount = 0.0
Set nFinalAmount = nInitialInvestment + nInvestmentEarning
Return nFinalAmount
End Function //end calcTotal
Module output(String nCustomerName, Real nInitialInvestment, Real nInvestmentEarnings, RealnFinalAmount)
Display "Your Name is: ", nCustomerName
Display "Your initial investment is: ", nInitialInvestment
Display "Your investment earning return is: ", nInvestmentEarnings
Display "Your final amount after 1 year is: ", nFinalAmount
End Module // end output