Pretty new to programming, sorry if basic question, first time doing modular work. Not sure what I'm doing wrong here, but line 41 ([ShowBalance] --> Case"C" spits out the error in the title when I try to run my program. What is nested improperly?
Balance=1000
Print "Banking Menu"
Do
Gosub[Menu]
Gosub[Deposit]
Gosub[Withdrawal]
Gosub[ShowBalance]
Loop Until Choice$="Q"
Print "Thanks for using the Banking Application"
End
[Menu]
Print "A. Deposit"
Print "B. Withdrawal"
Print "C. Show Balance"
Print "Q. Quit"
Input "Make Selection: ";Choice$
Select Case Upper$(Choice$)
Return
[Deposit]
Case "A"
Input "Enter Amount to Deposit: ";Dep
If Dep > 0 Then
Balance=Balance+Dep
Else
Print "Invalid Amount"
End If
Return
[Withdrawal]
Case "B"
Input "Enter Amount to Withdraw: ";Wdrw
If Wdrw <= 1000 Then
Balance=Balance-Wdrw
Else
Print "Invalid Amount"
Return
[ShowBalance]
Case "C"
Print
Print "*********************************"
Print "*** Account Balance: $";using("####.##",Balance);" ***"
Print "*********************************"
End Select
Print
Print "----------------------------"
Return
The
Caseinstructions belong to theSelect Caseinstruction. They must not get separated! Your program must always respect below layout without interveningReturninstructions.Solution without subroutines
You insert the instructions that perform the action directly below the corresponding
Caseinstruction. Disadvantage is that, if the number of instructions in an action block is elevated, you loose track of the wholeSelect Caseconstruct.Solution with subroutines Deposit, Withdrawal, and ShowBalance
You place the instructions that perform the action in separate subroutines and insert a mere
Gosubdirectly below the correspondingCaseinstruction. Advantage is that, even if the number of instructions in an action block is elevated, you keep a clear view on the wholeSelect Caseconstruct.