Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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 02 - ATM machine (25 points)

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.

image text in transcribed

Enter an id: Main menu 1: check balance 2: withdraw 3: deposit 4: exit Enter a choice: 1 The balance is 100.0 Main menu 1: check balance 2: withdraw 3: deposit 4: exit Enter a choice: 2 Enter an amount to withdraw: 3 WOW Main menu 1: check balance 2: withdraw 3: deposit 4: exit Enter a choice: 1 free The balance is 97.0 Main menu 1: check balance 2: withdraw 3: deposit 4: exit Enter a choice: 3 Peter Enter an amount to deposit: 10 E Main menu 1: check balance 2: withdraw 3: deposit 4: exit Enter a choice: 1 Werter The balance is 107.0 Main menu 1: check balance 2: withdraw 3: deposit 4: exit Enter a choice: Enter an id

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases And Python Programming MySQL MongoDB OOP And Tkinter

Authors: R. PANNEERSELVAM

1st Edition

9357011331, 978-9357011334

More Books

Students also viewed these Databases questions