Controlling Program Flow w/i an ATM Using selection statements & loops to complete the following: Validate...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Controlling Program Flow w/i an ATM Using selection statements & loops to complete the following: Validate the user's PIN -- only allow them to attempt three (3) times before ending the program If the PIN matched: O 。 Continuously prompt the user with menu options corresponding to the ATM's ○ functionality what options should we include here? ■ Suggestions: D: Deposit W: Withdraw Cash B: Display Current Balance P: Change PIN. о Must be length >= 4 && different from the previous Q: Program ends. Anything else: error message -- return to the main menu to try again. Read in the user's choice and use a switch statement to handle the appropriate functionality as suggested above To Do: Begin by downloading ATMMenu.java from CourseSite (Prep & Participation > Week 5 Resources). When you open this program, you will see that there is code written to display basic menu options for a menu-driven ATM system. You are going to complete the program to actually start implementing basic functionality for each menu option (included below): ATM Main Menu D: Deposit W: Withdraw Cash B: Display Current Balance P: Change PIN. Q: Program ends. 1. Begin by familiarizing yourself with the code provided. In the starting program, there are a handful of suggested variables declared (including a Scanner object). a. You may choose to use these variables to complete the requirements that follow, OR you can create your own. Either is fine. 2. Using selection statement(s) within a loop, you should write code to validate the user's PIN before prompting them with the menu options. a. Revisit the ATM activity from Week 3 for a hint about getting started with this. b. Note: the user should only have 3 chances to enter their PIN before being locked out. After that, end the program after sharing an error message. 3. After the PIN is validated, you should display the relevant menu options for the user. a. Note: there are print statements in the provided starting program with the menu options listed for the user (though you can/should move that code into an appropriate location based on intended program flow). 4. Prompt the user to select a menu option reading in the user's choice as a single character and validate the choice a. Validation: i. ii. If the user typed in a valid menu option ('D', 'W', ‘B', ‘P', ‘Q'), continue executing (go to step 5 below) Otherwise, if the user typed in something that was not valid, the program should display an error message and end. b. remember: there is no nextChar() method in the Scanner class. What options do we have to read in this data? 5. Use a switch statement to process the user's input to execute the correct path based on the user's valid input. Within each of these alternate paths of execution, there may be additional selection statements to utilize. i. ii. iii. iv. V. If the user enters 'D', the program should execute commands to deposit money into the machine. 1. Ask the user if they are depositing cash or checks, and for the amount. 2. Don't forget to change the user's current balance after depositing the money. If the user enters 'W', the program should prompt the user to select the amount of money that they want to withdraw 1. This number should be an integer/multiple of 20 2. Be sure that the user is not trying to withdraw more than they have available 3. Don't forget to change the user's current balance after depositing the money. If the user enters 'B', display their current balance (before displaying the menu again) If the user enters ‘P’, the program should execute the commands to change the current PIN 1. The new PIN must be at least 4 numeric digits long and cannot match the current PIN. 2. Be sure to let the user know which of those criteria fail, or that the PIN was successfully changed if both pass. If the user enters ‘Q', the program should display a message and end. 6. The program should continuously prompt the user to enter a choice until they type 'Q' 7. Requirements: a. Use at least one if-else Statement and one switch statement b. Use at least one of each type of loop (for, while, do while) Reminders: • THERE IS NO “RIGHT” ANSWER FOR THE ATM ACTIVITIES. You may choose to implement the program as you wish (as long as you are including any/all program requirements). If there is any functionality that you don't know how to implement using Java (yet), use a comment to describe what you are trying to do. Adhere to good programming practices (includes a header, comments, proper indentation, and descriptive variable names using camelCase) } public class ATMMenu{ Run | Debug public static void main(String[] args) { //1. verify the user's pin (allowing 3 incorrect attempts) //2. display the menu options and prompt the user to select a function //3. use a switch statement to evaluate the user's choice (or to tell them that they typed an incorrect value) //4. continuing prompting until the user types a 'Q' } System.out.println("ATM Main Menu"); System.out.println("D: Deposit"); System.out.println("W: Withdraw Cash"); System.out.println("B: Display Current Balance"); System.out.println("P: Change PIN."); System.out.println("Q: Program ends."); Controlling Program Flow w/i an ATM Using selection statements & loops to complete the following: Validate the user's PIN -- only allow them to attempt three (3) times before ending the program If the PIN matched: O 。 Continuously prompt the user with menu options corresponding to the ATM's ○ functionality what options should we include here? ■ Suggestions: D: Deposit W: Withdraw Cash B: Display Current Balance P: Change PIN. о Must be length >= 4 && different from the previous Q: Program ends. Anything else: error message -- return to the main menu to try again. Read in the user's choice and use a switch statement to handle the appropriate functionality as suggested above Controlling Program Flow w/i an ATM Using selection statements & loops to complete the following: Validate the user's PIN -- only allow them to attempt three (3) times before ending the program If the PIN matched: O 。 Continuously prompt the user with menu options corresponding to the ATM's ○ functionality what options should we include here? ■ Suggestions: D: Deposit W: Withdraw Cash B: Display Current Balance P: Change PIN. о Must be length >= 4 && different from the previous Q: Program ends. Anything else: error message -- return to the main menu to try again. Read in the user's choice and use a switch statement to handle the appropriate functionality as suggested above To Do: Begin by downloading ATMMenu.java from CourseSite (Prep & Participation > Week 5 Resources). When you open this program, you will see that there is code written to display basic menu options for a menu-driven ATM system. You are going to complete the program to actually start implementing basic functionality for each menu option (included below): ATM Main Menu D: Deposit W: Withdraw Cash B: Display Current Balance P: Change PIN. Q: Program ends. 1. Begin by familiarizing yourself with the code provided. In the starting program, there are a handful of suggested variables declared (including a Scanner object). a. You may choose to use these variables to complete the requirements that follow, OR you can create your own. Either is fine. 2. Using selection statement(s) within a loop, you should write code to validate the user's PIN before prompting them with the menu options. a. Revisit the ATM activity from Week 3 for a hint about getting started with this. b. Note: the user should only have 3 chances to enter their PIN before being locked out. After that, end the program after sharing an error message. 3. After the PIN is validated, you should display the relevant menu options for the user. a. Note: there are print statements in the provided starting program with the menu options listed for the user (though you can/should move that code into an appropriate location based on intended program flow). 4. Prompt the user to select a menu option reading in the user's choice as a single character and validate the choice a. Validation: i. ii. If the user typed in a valid menu option ('D', 'W', ‘B', ‘P', ‘Q'), continue executing (go to step 5 below) Otherwise, if the user typed in something that was not valid, the program should display an error message and end. To Do: Begin by downloading ATMMenu.java from CourseSite (Prep & Participation > Week 5 Resources). When you open this program, you will see that there is code written to display basic menu options for a menu-driven ATM system. You are going to complete the program to actually start implementing basic functionality for each menu option (included below): ATM Main Menu D: Deposit W: Withdraw Cash B: Display Current Balance P: Change PIN. Q: Program ends. 1. Begin by familiarizing yourself with the code provided. In the starting program, there are a handful of suggested variables declared (including a Scanner object). a. You may choose to use these variables to complete the requirements that follow, OR you can create your own. Either is fine. 2. Using selection statement(s) within a loop, you should write code to validate the user's PIN before prompting them with the menu options. a. Revisit the ATM activity from Week 3 for a hint about getting started with this. b. Note: the user should only have 3 chances to enter their PIN before being locked out. After that, end the program after sharing an error message. 3. After the PIN is validated, you should display the relevant menu options for the user. a. Note: there are print statements in the provided starting program with the menu options listed for the user (though you can/should move that code into an appropriate location based on intended program flow). 4. Prompt the user to select a menu option reading in the user's choice as a single character and validate the choice a. Validation: i. ii. If the user typed in a valid menu option ('D', 'W', ‘B', ‘P', ‘Q'), continue executing (go to step 5 below) Otherwise, if the user typed in something that was not valid, the program should display an error message and end. b. remember: there is no nextChar() method in the Scanner class. What options do we have to read in this data? 5. Use a switch statement to process the user's input to execute the correct path based on the user's valid input. Within each of these alternate paths of execution, there may be additional selection statements to utilize. i. ii. iii. iv. V. If the user enters 'D', the program should execute commands to deposit money into the machine. 1. Ask the user if they are depositing cash or checks, and for the amount. 2. Don't forget to change the user's current balance after depositing the money. If the user enters 'W', the program should prompt the user to select the amount of money that they want to withdraw 1. This number should be an integer/multiple of 20 2. Be sure that the user is not trying to withdraw more than they have available 3. Don't forget to change the user's current balance after depositing the money. If the user enters 'B', display their current balance (before displaying the menu again) If the user enters ‘P’, the program should execute the commands to change the current PIN 1. The new PIN must be at least 4 numeric digits long and cannot match the current PIN. 2. Be sure to let the user know which of those criteria fail, or that the PIN was successfully changed if both pass. If the user enters ‘Q', the program should display a message and end. 6. The program should continuously prompt the user to enter a choice until they type 'Q' 7. Requirements: a. Use at least one if-else Statement and one switch statement b. Use at least one of each type of loop (for, while, do while) b. remember: there is no nextChar() method in the Scanner class. What options do we have to read in this data? 5. Use a switch statement to process the user's input to execute the correct path based on the user's valid input. Within each of these alternate paths of execution, there may be additional selection statements to utilize. i. ii. iii. iv. V. If the user enters 'D', the program should execute commands to deposit money into the machine. 1. Ask the user if they are depositing cash or checks, and for the amount. 2. Don't forget to change the user's current balance after depositing the money. If the user enters 'W', the program should prompt the user to select the amount of money that they want to withdraw 1. This number should be an integer/multiple of 20 2. Be sure that the user is not trying to withdraw more than they have available 3. Don't forget to change the user's current balance after depositing the money. If the user enters 'B', display their current balance (before displaying the menu again) If the user enters ‘P’, the program should execute the commands to change the current PIN 1. The new PIN must be at least 4 numeric digits long and cannot match the current PIN. 2. Be sure to let the user know which of those criteria fail, or that the PIN was successfully changed if both pass. If the user enters ‘Q', the program should display a message and end. 6. The program should continuously prompt the user to enter a choice until they type 'Q' 7. Requirements: a. Use at least one if-else Statement and one switch statement b. Use at least one of each type of loop (for, while, do while) Reminders: • THERE IS NO “RIGHT” ANSWER FOR THE ATM ACTIVITIES. You may choose to implement the program as you wish (as long as you are including any/all program requirements). If there is any functionality that you don't know how to implement using Java (yet), use a comment to describe what you are trying to do. Adhere to good programming practices (includes a header, comments, proper indentation, and descriptive variable names using camelCase) Reminders: • THERE IS NO “RIGHT” ANSWER FOR THE ATM ACTIVITIES. You may choose to implement the program as you wish (as long as you are including any/all program requirements). If there is any functionality that you don't know how to implement using Java (yet), use a comment to describe what you are trying to do. Adhere to good programming practices (includes a header, comments, proper indentation, and descriptive variable names using camelCase) } public class ATMMenu{ Run | Debug public static void main(String[] args) { //1. verify the user's pin (allowing 3 incorrect attempts) //2. display the menu options and prompt the user to select a function //3. use a switch statement to evaluate the user's choice (or to tell them that they typed an incorrect value) //4. continuing prompting until the user types a 'Q' } System.out.println("ATM Main Menu"); System.out.println("D: Deposit"); System.out.println("W: Withdraw Cash"); System.out.println("B: Display Current Balance"); System.out.println("P: Change PIN."); System.out.println("Q: Program ends."); } public class ATMMenu{ Run | Debug public static void main(String[] args) { //1. verify the user's pin (allowing 3 incorrect attempts) //2. display the menu options and prompt the user to select a function //3. use a switch statement to evaluate the user's choice (or to tell them that they typed an incorrect value) //4. continuing prompting until the user types a 'Q' } System.out.println("ATM Main Menu"); System.out.println("D: Deposit"); System.out.println("W: Withdraw Cash"); System.out.println("B: Display Current Balance"); System.out.println("P: Change PIN."); System.out.println("Q: Program ends.");
Expert Answer:
Answer rating: 100% (QA)
Heres a basic implementation of the ATMMenu class based on the requirements provided import javautilScanner public class ATMMenu public static void ma... View the full answer
Related Book For
Principles of Managerial Finance
ISBN: 978-1408271582
Arab World Edition
Authors: Lawrence J. Gitman, Chad J. Zutter, Wajeeh Elali, Amer Al Roubaix
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
QUESTION 17 The moment of a force about a pivot point is; a. The force multiplied by the perpendicular distance fro the pivot point to the direction of the force b. the distance from the pivot to the...
-
A coil with 190 turns, a radius of 5.0 cm, and a resistance of 12 Ω surrounds a solenoid with 230 turns / cm and a radius of 4.5 cm (Fig. 21-65). The current in the solenoid changes at a...
-
Below is a transcript of a May video conference between Joe Anthony, the partner, and Leslie Nagan, the manager. JA: Leslie, I just ended a call with Avis. Finally, some good news. Avis said that...
-
1. Working in small groups, complete the Pay Raise Worksheet. 2. After the class reconvenes, group spokespersons present group findings. Pay Raise Worksheet April Knepper is the new supervisor of an...
-
On May 1, 2008, Friendly Company issued 2,000 $1,000 bonds at 102. Each bond was issued with one detachable stock warrant. Shortly after issuance, the bonds were selling at 98, but the market value...
-
Q5). Given the graph y= f(x), graph y=[-2(x-1)]-2 on the same grid on your right. Use at least 4 points: Show steps
-
What is the correct GST code to use for 'paid electrical repairs in upstairs residential apartment'? The options are = GST Free, Input Taxed Supply, Input taxed and Exports.
-
Dr. Rogers attaches a 0.5 kg mass to an ideal spring and starts it oscillating. It takes the mass a total time of 2.5 s from the first time passing through the equilibrium position to the second time...
-
With her new trainer, Gabrielle now bikes at an average speed of 22.5MPH. That is 31.3% faster than she averaged with her old trainer. How fast did she bike, on average, before training with the her...
-
CJ Investments Limited is seeking financing from Republic Bank Limited. They currently own a small strip mall in Port-of-Spain (freehold interest) that comprises 25 identical shop units, each with a...
-
A 320 g bird flying along at 6.5 m/s sees a 12 g insect heading straight toward it with a speed of 30 m/s (as measured by an observer on the ground, not by the bird). The bird opens its mouth wide...
-
A certain stock opens with a price of $2.44. Over the firsithree days, the value of the stock increases on average by 30% per day. If this trend continues, how many days will it take for the stock to...
-
You are a financial advisor operating as an authorised representative of an AFS licensee with Universal Financial Planning (UFP) Pty Ltd. Two new clients approach you seeking some advice. They are a...
-
For Problem estimate the change in y for the given change in x. y = f(x), f'(12) = 30, x increases from 12 to 12.2
-
The Bahrain Petroleum Company (BAPCO) is considering two mutually exclusive projects. Each requires an initial investment of US$100,000. Faisal AlMahroos, president of the company, has a maximum...
-
Casablanca Paper has the following stockholders' equity account. The firm's common stock has a current market price of US$30 per share. Preferred...
-
P&K Tool is considering lengthening its credit period from 30 to 60 days. All customers will continue to pay on the net date. The firm currently bills US$450,000 for sales and has US$345,000 in...
-
Because of the negative incentive effect that taxes have on goods with elastic supply, in the late 1980s Margaret Thatcher (then prime minister of Great Britain) changed the property tax to a poll...
-
Many of the buildings in Paris have Mansard roofs, such as those shown in the photograph on page 147. a. What property tax structure would bring this about? b. Could you imagine a change in the...
-
On September 29, 2008, the stock market fell almost 7%. How can we reconcile these kinds of huge losses in the stock market with the efficient market hypothesis?
Study smarter with the SolutionInn App