Program Description: An application that involves a menu system limits the choic
ID: 3689614 • Letter: P
Question
Program Description: An application that involves a menu system limits the choices a user can make so that only valid options are processed. The simplest menu system displays a number of user choices and processes the one the user selects. If the user is expected to make only one choice and then quit, a selection structure can be used.
The most common model is a menu that stays onscreen to use repeatedly, instead of a menu that allows users to make only one choice. To create a menu that’s used more than once, a repetition structure that encloses the selection structure is more suitable, where you add a choice for the user to exit the menu. As a form of data validation, you should display an error message if the user doesn’t enter a valid choice (including the exit choice).
Given the following algorithm (see following pages), write a program that displays a menu prompting the user to choose their banking option. The algorithm uses a repetition structure. The user will be presented the menu until the user selects the option to exit the application. You are required to write the program using the following:
• while loop – “SeminoleBank_A.java”
• do-while loop – “SeminoleBank_B.java”
Algorithm for "SeminoleBank_A.java"
//Declarations and Initializations of variables
Declare and initialize deposit
Declare and initialize withdrawal
Declare and initialize current balance [HINT: Assume that the initial balance for all customers is: 1000.00] [HINT: Other variables may be needed!!!]
//Display welcome messages and Request and Read users’ account number
Display welcome message “Seminole Bank”
Display welcome message “Welcome to Seminole Bank!”
Display “Please enter your 5-digit Account Number: ”
Read user’s account number
Display “Thank you!!”
//Display menu choices and Request and Read the users’ banking choice
Display “Enter D for deposit, W for withdrawal, B for balance, X to exit the menu: “
Read the user’s menu choice
Ensure user input has correct case [HINT: menu choice = Character.toUpperCase(menu choice)]
//Process menu until user enters X (Use a WHILE loop with an “if…else if” or a “switch”)
While the menu choice is not “X”
If the menu choice is “D”,
Display “Enter the amount of the deposit: “
Read the deposit amount
Calculate the current balance after the deposit [current balance = current balance + deposit amount]
Else If the menu choice is “W”,
Display “Enter the amount of the withdrawal: “
Read the withdrawal amount
Calculate the current balance after the withdrawal [current balance = current balance + withdrawal amount]
Else If the menu choice is “B”,
Display “Account Number: “ (INSERT THE ACCOUNT NUMBER) “ has a current balance of : $ “ current balance
Else
Display “ERROR: Please enter a D, W, B, or X: “
//Display menu choices and Request and Read the users’ banking choice
Display “Enter D for deposit, W for withdrawal, B for balance, X to exit the menu: “
Read the user’s menu choice
Ensure user input has correct case [HINT: menu choice = Character.toUpperCase(menu choice)]
End Loop
//Display final message Display
“Thank you for being a loyal Seminole Bank customer!”
HINTS:
• Hint #1: The program should allow the user to type in the choices using any case. In order to account for user input, consider the following example: o menu choice = Character.toUpperCase(menu choice)
• Hint #2: Assume that the initial balance for all customers is: $1000.00
• Hint #3: All dollar amounts should display two digits after the decimal place. Consider the following example: o System.out.printf("……..%.2f…..", dollar amounts);
Sample Run #1: Welecome to Seminole Bank! Please enter your 5-digit Seminole Account Number: 64521 Thank you Enter D for deposit, W for withdrawal, B for balance or X to exit the menu: B Account Number: 64521 has a current balance of $1000.00 Enter D for deposit, W for withdrawal, B for balance or X to exit the menu: D Enter the amount of the deposit: 600 Enter D for deposit, W for withdrawal, B for balance or X to exit the menu: b Account Number: 64521 has a current balance of: $16e6. Enter D for deposit, W for withdrawal, B for balance or X to exit the menu: w Enter the amount of the withdrawal: 100 Enter D for deposit, W for withdrawal, B for balance or X to exit the menu: b Account Number: 64521 has a current balance of: $1500.00 Enter D for deposit, W for withdrawal, B for balance or X to exit the menu: x Thank you for being a loyal Seminole Bank customerExplanation / Answer
---------------------------------------------------------------------------------------------------------------------------------------------
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.