Description
❐Part 1: CoffeeShopAccount [25 points]
File Name: CoffeeShopAccount.java Problem Description: You are an owner of a small coffee shop and you want to keep tabs of your shop’s balance, money in, money out and have a very light security using 4 digit PIN. Write a program to perform the following operations: 1. Check balance: This operation should display total losses or profit available, can be negative or positive
2. Money in: This operation should pay down any debt or add to the profit 3. Money out: This operation should subtract the amount from the available balance 4. Set or change a 4 digit PIN number: This operation should change the 4 digit pin number 5. Exit: Terminate the program execution Functional requirements: User shall be able to : 1. Choose from the menu what action to perform 2. Add money into the balance, and see their ending balance. Can be positive/ negative
3. Extract money from the balance, and see their ending balance. Can be positive/ negative. 4. Set up a 4-digit PIN 5. Exit immediately when the option to exit is chosen Tips: 1. All the methods are mainly updating the main Balance, except the update PIN method.
Balance therefore will be a value that needs to be access by all methods, therefore it needs to be passed into the method as a parameter 2. You can use System.out.print(“ with \n “); to format your menus and use System.out.printf(“… to print out your $ dollar amount using 2 decimals after decimal point .2f and %n for a new line”, value);
3. Create your program using the following best practice: First: // Type out the steps to creating your program, be specific in what needs to be global, or local, and inside or outside the loop Second: Create your code as if you don’t have any methods. Test that it is working first before creating methods. Third: Copy and paste your code from main into your various methods. Test that it is still working as expected. 4. Variables, we will consider them global, to declare in the main method: balance, pin, which can be accessed by all the methods.
5. Analyzing values: 1. Ask the user to enter the PIN and display the available balance only when the answer is correct.
use equals method to compare String: Syntax: s1.equals(s2) here s1 and s2 are String variables 2. Or use == method to compare PIN that is an integer int1 == int2 2. Withdraw balance only when the withdrawal amount is less than or equal to balance.
Rules & Guidelines:
1. You may assume the user will always enter the correct dollar in double format and menu in integer format 2. If the user enters any other number not in the menu, simply print a message that it is invalid and loop through the menu agaijavan. 3. Create at least 4 methods 4. Use a switch case to call the method that performs the operation. • E.g. If the user enters 1 to check balance then call that method 5. Create any additional methods you like
6. Name your methods as camelCased, and action-oriented, i.e. actionValue, getBalance, setBalance, spendBalance, etc. 7. Use while loop to display the bank operations and terminate the loop on Exit (i.e. operation 5) 8. Variables to declare in the main method: balance, pin
Case of wrong PIN entered: Example: Please paste your screenshot for this scenario here: Output :
0 Correct values entered: Please paste your screenshot for this scenario here: Output :
Changing PIN number Please paste your screenshot for this scenario here: Output :
Invalid Menu option output: Please paste your screenshot for this scenario here: Output :
Not enough money in the balance to spend output: Please paste your screenshot for this scenario here: Output :
SUBMISSION INSTRUCTIONS 1. Submit the 1 CoffeeShopAccount.java file directly on iLearn
❐Part 2: Reflect with a Buddy 50 words [13 points]
1. Find your buddy. Look at the Study Buddy sheet and pair up with your assigned buddy. Or find someone to partner this task with. 2. You can set up a Slack, Discord, or a Zoom with your buddy to asynchronously or synchronously talk about anything, and also reflect on what was helpful and not helpful in completing this homework.
3. Each student will need to create 1 post to mark this assignment as complete. Have fun with this one!! 👋 Assignment 5