The goal of this Project is:

  • Being able to Analyze, Design, implement, and test a practical real-world application.
  • Being able to use selections and repetition structures
  • Being able to deal with methods
  • Being able to manipulate 1D & 2D arrays.
  • Learn about user-defined classes

Requirements:

  • In a word file:
    • Analyze each problem; outline the problem and its solution requirements. (Describe the problem including input and output in your own words.))
    • Design an algorithm to solve the problem. (Describe the major steps for solving the problem.) Use UML class diagram to model the class in question 2.
  • Using java IDE software, implement the algorithm.
  • Test the code for each problem and verify that the algorithm works; include a screenshot of each program output.

Question 01 - Pattern recognition: four consecutive equal numbers

Write the following method that tests whether a two-dimensional array has four consecutive numbers of the same value, either horizontally, vertically, or diagonally:

public static boolean isConsecutiveFour(int[][] values)

Write a test program that prompts the user to enter the number of rows and columns of a two-dimensional array then the values in the array, and displays true if the array contains four consecutive numbers with the same value. Otherwise, the program displays false. Here are some examples of the true cases: see image.

Question 02 - ATM machine

Write a class named Account that contains:

  • A private int data field named id for the account (default 0).
  • A private double data field named balance for the account (default 0).
  • A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume that all accounts have the same interest rate.
  • A private Date data field named dateCreated that stores the date when the account was created.
  • A no-arg constructor that creates a default account.
  • A constructor that creates an account with the specified id and initial balance.
  • The accessor and mutator methods for id, balance, and annualInterestRate.
  • The accessor method for dateCreated.
  • A method named getMonthlyInterestRate() that returns the monthly interest rate.
  • A method named getMonthlyInterest() that returns the monthly interest not the interest rate.
  • A method named withdraw that withdraws a specified amount from the account.
  • A method named deposit that deposits a specified amount to the account.

Note:

Monthly interest is balance * monthlyInterestRate.
monthlyInterestRate is annualInterestRate / 12.
annualInterestRate is a percentage, for example 4.5%. You need to divide it by 100.

Draw the UML diagram for the class then implement the class.

Create another class (TestAccount) that uses the Account class created above to simulate an ATM machine. Create 10 accounts in an array with id 0, 1, . . . , 9, and an initial balance of $100. The system prompts the user to enter an id. If the id is entered incorrectly, ask the user to enter a correct id. Once an id is accepted, the main menu is displayed as shown in the sample run. You can enter choice 1 for viewing the current balance, 2 for withdrawing money, 3 for depositing money, and 4 for exiting the main menu. Once you exit, the system will prompt for an id again. Thus, once the system starts, it will not stop.

Sample output: see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.