课程: Hands-On Introduction: Java

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Display menu options

Display menu options

- [Instructor] After we allow the user to authenticate, we want to show them a menu of options. Within the showMenu method of the menu class, we'll keep track of the user's selection with the variable which we'll initially set to 0. We can call this variable selection. Let's then provide menu options for deposit, withdrawal, check balance, and exit, where each of the menu options have a corresponding number between 1 and 4. We'll once allow the users to continue with as many transactions as they like, so we can use a loop to continuously show them their menu options after they complete a transaction. Because the loop needs to be controlled by a condition, and we're not sure how many transactions the customer will want to make, a while loop is our best option. So we'll write our while, and we can say continue allowing transactions while the menu option is not equal to 4, so while selection is not equal to 4, and while…

内容