Question

AccountSaving.java This program question is to be completed in Java Programming language Can you Create a...

AccountSaving.java

This program question is to be completed in Java Programming language


Can you Create a class called AccountSaving.java that will extend a type of file called AccountPersonal.java.

AccountSaving should be in its own file called AccountSaving.java. A saving account cannot withdraw more than its balance. AccountSaving should have the following characteristics.


 Create A constructor that takes the specified customer name, id, balance, annual interest rate, and date created. Make sure that you call the constructor in the AccountPersonal.


 Create A constructor that takes the specified customer name, id, and balance. This constructor should simply call the above constructor passing the received information along with default values for the remaining information. Pass 0.0 for the annual interest rate and the current date for the date created.


 Create an Override for the toString method. The toString method should output everything the AccountPersonal toString method does plus the Account type.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

// AccountPersonal.java

import java.util.Date;   

public class AccountPersonal {   
   private String name;   
   private int id;
   private double balance;
   private double annualInterestRate;   
   private Date dateCreated;

   /**
   * @param name   
   * @param id   
   * @param balance
   * @param annualInterestRate   
   * @param dateCreated
   */
   public AccountPersonal(String name, int id, double balance,
           double annualInterestRate, Date dateCreated) {   

       this.name = name;
       this.id = id;
       this.balance = balance;
       this.annualInterestRate = annualInterestRate;
       this.dateCreated = dateCreated;
   }

   /**
   * @return the name
   */
   public String getName() {
       return name;   
   }

   /**
   * @param name the name to set   
   */
   public void setName(String name) {   
       this.name = name;
   }

   /**
   * @return the id
   */
   public int getId() {   
       return id;   
   }

   /**
   * @param id the id to set   
   */
   public void setId(int id) {
       this.id = id;
   }

   /**
   * @return the balance   
   */
   public double getBalance() {   
       return balance;
   }

   /**
   * @param balance the balance to set   
   */
   public void setBalance(double balance) {   
       this.balance = balance;
   }

   /**
   * @return the annualInterestRate
   */
   public double getAnnualInterestRate() {
       return annualInterestRate;   
   }

   /**
   * @param annualInterestRate the annualInterestRate to set   
   */
   public void setAnnualInterestRate(double annualInterestRate) {   
       this.annualInterestRate = annualInterestRate;
   }

   /**
   * @return the dateCreated   
   */
   public Date getDateCreated() {   
       return dateCreated;
   }

   /**
   * @param dateCreated the dateCreated to set   
   */
   public void setDateCreated(Date dateCreated) {   
       this.dateCreated = dateCreated;
   }




   @Override
   public String toString() {   
       return "Name=" + name + ", id=" + id + ", balance="
               + balance + ", annualInterestRate=" + annualInterestRate   
               + ", dateCreated=" + dateCreated;
   }
     
     

}

_____________________________

// AccountSavings.java

import java.util.Date;


public class AccountSavings extends AccountPersonal {

   public AccountSavings(String name, int id, double balance,
           double annualInterestRate, Date dateCreated) {
       super(name, id, balance,0.0,new Date());
   }


   @Override
   public String toString() {
       return "AccountSavings "+super.toString();
   }

}
________________________

// Test.java

import java.util.Date;

public class Test {

   public static void main(String[] args) {
       AccountSavings ac=new AccountSavings("Kane Williams",1233,50000,13.5,new Date());
       System.out.println(ac);

   }

}
_________________________

Output;

AccountSavings Name=Kane Williams, id=1233, balance=50000.0, annualInterestRate=0.0, dateCreated=Sun Nov 24 10:02:39 IST 2019

________________________Thank You

Add a comment
Know the answer?
Add Answer to:
AccountSaving.java This program question is to be completed in Java Programming language Can you Create a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in java Account that contains: balance: double data field date: Date data field. Use Date class...

    in java Account that contains: balance: double data field date: Date data field. Use Date class from the java.util package accountNumber: long data field. You should generate this value randomly. The account number should be 9 digits long. You can you random method from java Math class. annuallnterestRate: double data field. customer: Customer data field. This is the other class that you will have to design. See description below. The accessor and mutator methods for balance, annuallnterestRate, date, and customer....

  • This is for java programming Please Show plenty of comments so I can follow the steps...

    This is for java programming Please Show plenty of comments so I can follow the steps Design 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 all accounts have the same interest rate. • A private Date data field named...

  • In C++ Write a program that contains a BankAccount class. The BankAccount class should store the...

    In C++ Write a program that contains a BankAccount class. The BankAccount class should store the following attributes: account name account balance Make sure you use the correct access modifiers for the variables. Write get/set methods for all attributes. Write a constructor that takes two parameters. Write a default constructor. Write a method called Deposit(double) that adds the passed in amount to the balance. Write a method called Withdraw(double) that subtracts the passed in amount from the balance. Do not...

  • Need help creating a Java program with mandatory requirements! VERY IMPORTANT: The George account class instance...

    Need help creating a Java program with mandatory requirements! VERY IMPORTANT: The George account class instance must be in the main class, and the requirement of printing a list of transactions for only the ids used when the program runs(Detailed in the Additional simulation requirements) is extremely important! Thank you so very much! Instructions: This homework models after a banking situation with ATM machine. You are required to create three classes, Account, Transaction, and the main class (with the main...

  • Write a Java class called BankAccount (Parts of the code is given below), which has two...

    Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...

  • Write a Java class called BankAccount (Parts of the code is given below), which has two...

    Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...

  • Please help JAVA Part II: Programming Module (80 marks): Write a banking program that simulates the operation of your l...

    Please help JAVA Part II: Programming Module (80 marks): Write a banking program that simulates the operation of your local bank. You should declare the following collection of classes: 1) An abstract class Customer: each customer has: firstName(String), lastName (String), age (integer), customerNumber (integer) - The Class customer has a class variable lastCustomerNumber that is initialized to 9999. It is used to initialize the customerNumber. Hence, the first customer number is set to 9999 and each time a new customer...

  • Application should be in C# programming language Create a class called SavingsAccount.  ...

    Application should be in C# programming language Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the...

  • JAVA PROGRAMMING LANGUAGE!!!! JAVA PROGRAMMING LANGUAGE!!!! JAVA PROGRAMMING LANGUAGE!!!! Bank Account and Savings Account Classes Design...

    JAVA PROGRAMMING LANGUAGE!!!! JAVA PROGRAMMING LANGUAGE!!!! JAVA PROGRAMMING LANGUAGE!!!! Bank Account and Savings Account Classes Design an abstract class named BankAccount to hold the following data for a bank account: • Balance • Number of deposits this month • Number of withdrawals • Annual interest rate • Monthly service charges The class should have the following methods: Constructor:   The constructor should accept arguments for the balance and annual interest rate. deposit:             A method that accepts an argument for the amount of...

  • Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and...

    Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT