Would you like to fit together 2000 pieces of a program-puzzle without any framework?
Only if I were paid lots of money per hour.
Congratulations! You now understand why programmers are paid lots of money (and don't have a life...) The framework that greatly helps in fitting the small tasks together is made up of control structures. You may recall that this is called structured programming.
Let us run the program and look at its output. Here is the program:
' Get the starting balance PRINT "What is the starting balance" INPUT BALANCE ' ' Determine transaction type PRINT "Type a 'D' for a deposit or a 'C' for a check" INPUT TYPE$ ' IF TYPE$ = "D" THEN ' Process a deposit. PRINT "What is the deposit amount" INPUT DEPOSIT LET BALANCE = BALANCE + DEPOSIT ELSE ' Process a check. PRINT "What is the check amount" INPUT CHECK LET BALANCE = BALANCE - CHECK END IF ' ' Print the new balance. PRINT "The new balance is", BALANCE ' END
Say that the user wanted to make a Deposit of $1000, and already has $500.32 in the account. Here is the dialogue with the user:
What is the starting balance ? 500.32 Type a 'D' for a deposit or a 'C' for a check ? D What is the deposit amount ? 1000 The new balance is 1500.32
Say that the user also had a check of $25.10 to record. What must the user do now?