Can someone help me create the following account class pleas

Can someone help me create the following account class please / this is to be done using a java class file on Netbeans 8.1

Question 4 (5 marks) Design a class named Account that contains: A private int data field named id for the account (default o) 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 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. · A method named withdraw that withdraws a specified amount from the account. A method named deposit that deposits a specified amount to the account. Use the Account class to simulate an ATM machine. Create ten accounts in an array with id o, 1, . . . 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 a 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. 9, and initial balance $100. The system prompts the user to

Solution

import java.util.*;
import java.text.*;

class Account
   {
       private int id;
       private double balance;
       private double annualRate;
       private Date dateCreated;
      
       Account()
           {
               id = 0; balance = 0.0; annualRate = 0;
               //DateFormat df = new SimpleDateFormat(\"dd/MM/yy HH:mm:ss\");
               dateCreated = new Date();
               //String acntDate = df.format(dateCreated);
           }
          
       Account(int id, double balance)
           {
               this.id = id;
               this.balance = balance;
               dateCreated = new Date();
           }
          
       private void setId(int id)
           {
               this.id = id;
           }
       public int getId()
           {
               return id;
           }
          
          
       private void setBalance(double balance)
           {
               this.balance = balance;
           }
       public double getBalance()
           {
               return balance;
           }
          
          
       private void setAnnualRate(double annualRate)
           {
               this.annualRate = annualRate;
           }
          
       public double getAnnualRate()
           {
               return annualRate;
           }                      
          
       public String getDateCreated()
           {
               return dateCreated.toString();
           }
          
       public double getMonthlyInterestRate()
           {
               return annualRate/12;
           }
      
       public double getMonthlyInterest()
           {
               return balance * getMonthlyInterestRate();
           }
          
       public void deposit(double amt)
           {
               balance = balance + amt;
               System.out.println(\"Amount : \" + amt + \" has been deposited. Current balance is : \" + balance);
           }
          
       public void withdraw(double amt)
           {
               balance = balance - amt;
               System.out.println(\"Amount : \" + amt + \" has been withdrawn. Current balance is : \" + balance);              
           }
   }
  
public class AccountTester
   {
       public static void main(String args[])
           {
               Account[] a = new Account[10];
               a[0] = new Account(0,100.0);
               a[1] = new Account(1,100.0);
               a[2] = new Account(2,100.0);
               a[3] = new Account(3,100.0);
               a[4] = new Account(4,100.0);
               a[5] = new Account(5,100.0);
               a[6] = new Account(6,100.0);
               a[7] = new Account(7,100.0);                      
               a[8] = new Account(8,100.0);
               a[9] = new Account(9,100.0);
                                                  
               System.out.println(\"Enter ID\");
               Scanner s = new Scanner(System.in);
               int x = s.nextInt();
              
               for(int i=0;i<a.length;i++)
                   {
                       if(x!=a[i].getId())
                           {
                               System.out.println(\"Enter Valid ID\");
                               break;
                           }
                       else
                           {
                               System.out.println(\"MENU\");
                               System.out.println(\"1. VIEW BALANCE\");
                               System.out.println(\"2. WITHDRAW MONEY\");
                               System.out.println(\"3. DEPOSIT MONEY\");                                                              
                               System.out.println(\"4. EXIT\");                              
                               System.out.println(\"Enter a Choice\");
                               int ch = s.nextInt();
                              
                               switch(ch)
                                   {
                                       case 1: System.out.println(a[x].getBalance());
                                               break;
                                              
                                       case 2: System.out.println(\"Enter the amount to withdraw\");
                                               double amount = s.nextDouble();
                                               a[x].withdraw(amount);

                                       case 3: System.out.println(\"Enter the amount to deposit\");
                                               double amount1 = s.nextDouble();
                                               a[x].deposit(amount1);
                                              
                                       case 4: System.exit(0);  
                                   }
                           }
                   }
           }
   }

Can someone help me create the following account class please / this is to be done using a java class file on Netbeans 8.1 Question 4 (5 marks) Design a class n
Can someone help me create the following account class please / this is to be done using a java class file on Netbeans 8.1 Question 4 (5 marks) Design a class n
Can someone help me create the following account class please / this is to be done using a java class file on Netbeans 8.1 Question 4 (5 marks) Design a class n

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site