Calling option from menu function
Mostra commenti meno recenti
The code has main menu based on ATM macine. 1-Get cash. 2-Get Balance. 3-Quit % if user choose option 1
Mainmenu= menu('Main Menu','1-Get Cash','2-Get Balance','3-Quit');
if Mainmenu ==1
In Get Cash, Another menu that the user have to choose how much to withdraw
GetCashM= menu('Withdrawal amount','20$','40$','100$','200$');
, and after that, another menu to prompt the user to select 1- checking, 2- savings,
Acct= menu('From which account','checking','Saving');
and disp how many 20 bills were dispansed that is after verifying if there are enough funds in the selected account. And when option 1 or 2 are processed, the main menu will show again. I got that done. But, If option 3- quit selected, display New checking Balance and New Saving Balance. But how can I subtract the withdraw amount from checking savings account since menu option are string I think. Even if I called it it would be 1 or 2 or 3 or 4 respectivly to withdraw amount menu.
(ex)
Sbal = 100;
if the user withdrew 20$ from Sbal . "in option 1 from whidraw amount "
"second iteration."
if MainMenu ==. 3 % if the user choose option quit after proseccing whidraw amount
NewSavBal = GetCashMenu - SBal;
but that did not do it since values inside menu were string.
Keep in mind that
- If the user closes the menu rather than making a selection, warning message should bedisplayed and the user given 2 more chances to make a selection from that menu. If they still close the menu on the 3rd attempt, an error message should be displayed that says the program has been terminated.
7 Commenti
Walter Roberson
il 20 Apr 2019
menu() does not return strings or character vectors. menu() returns the relative choice in numeric form -- first option such as the '20$' returns 1, second option such as the '40$' returns 2, and so on.
mat geek
il 20 Apr 2019
Walter Roberson
il 20 Apr 2019
warncount = 0;
while true
MainMenu = menu(....)
if MainMenu == 0
if warncount == 3
error
else
warning
warncount = warncount + 1;
end
else
do something appropriate
warncount = 0;
end
end
Walter Roberson
il 21 Apr 2019
After your tests for specific Acct values you want plain if not elseif
mat geek
il 21 Apr 2019
mat geek
il 21 Apr 2019
Risposte (0)
Categorie
Scopri di più su Big Data Processing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!