Could I get some tips and opinion on my current pseudocode design? I'm new to coding and it's a bit of a learning curve for me

/*******************************************************************************

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:

  1. investment return rate = 0.05 - const Real

User:

  1. customer name - variable String
  2. initial investment - variable Real

Processing:

  1. Calculate investment earnings = initial investment * investment return rate
  2. Calculate final amount = investment earnings + initial investment

Output:

  1. customer name
  2. initial investments
  3. investment earnings
  4. 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

Hey @Maddox!

I found some articles that might help you with writing pseudo-code.

Hope this helps!

1 Like

I’ll read this article. Thanks!

1 Like