Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java

Can someone help me with this Java project?

This class will contain your main method and will operate a bit like an ATM. Your program should begin as specified below:

  1. Start the program by creating an array of 5 Account objects. Use an array. The type of the array is Account, not String, not int, and not double.
  2. You as the programmer will manually set the values for all 5 Accounts in the array. Do this directly in your code, not by using the Scanner. You can choose anything conventional for these values and you can add them directly through the constructor at object creation or using setters. (Typically I’d have you set it so that the user will initially fill these but that significantly increases the time it takes for me to grade this type of project.)

    Once the steps above have been set up, the actual user-interaction part of the program begins.

The program starts by asking the user for their account number or allowing them to exit the program. If they choose to exit, the program should delete all accounts and then it should end. If they enter anything other than the exit prompt, you will then need to see if that account number is present in the array of Account objects. If that number is not present, the user will be informed and the initial menu will repeat.

If the account number IS present, you will then present the user with 5 options.

  1. See Account Info
  2. Withdraw Money
  3. Deposit Money
  4. Reset PIN
  5. Return to Main Menu

Each Menu option is explained below.

  1. See Account Info – Print the toString() for that user so that they can see their name, account number, balance, and PIN.
  2. Withdraw Money – Ask the user how much money they want to withdraw. Call the withdraw() method and pass in their amount. No additional checks are necessary here. Just let the print statements in the withdraw() method do their thing. You are welcome to add additional code that would ask the user to re-enter a value if they enter a negative number but this is optional.
  3. Deposit Money – Ask the user how much they want to deposit. Call the deposit() method and pass in the amount entered. A confirmation print would be good here if one is not included in the deposit() method. No additional checks required.
  4. Reset PIN – For this option, you should first SHOW the user what their current PIN is using the getter and then ask them what they want the new PIN to be. Use the setter for the PIN to set their new PIN. You may add conditions to this if you want (limiting them to a certain number of characters or not letting them reset it to the same thing, etc.) but these are not required.
  5. Return to Main Menu – Leave the inner loop and return back to the outer loop so that a new user can enter their account number.

Once the user is within this second menu, they should be able to perform as many actions as they want between options 1-4 without having to re-enter their account number. Only when they decide to Return to Main Menu does it essentially “start over” so that a new person can enter their account number.

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, CAMILIO OCASIO! We can probably help you debug, but without the code that is failing it will be hard to help you debug this. We're not going to write the solution for you. We can help you arrive at the solution through problem-solving, though.

To share your code with us so that we can help you debug, please publish it to a public GitHub repository and then post back a link to your GitHub repo.

Hope this helps! :sparkles: