Question
Please write Java program with comments The Account) class Create a class named Account which has the following private properties: e number: long balance: double
Please write Java program with comments The Account) class Create a class named Account which has the following private properties: e number: long balance: double Create a no-argument constructor that sets the number and balance to zero. Create a two-parameter constructor that takes an account number and balance. First, implement getters and setters: getNumber),getBalance() setBalance(double newBalance) There is no setNumber) once an account is created, its account number cannot change. Now implement deposit (double amount) and withdraw(double amount) methods. If the amount is less than zero, the account balance remains untouched. If the amount is greater than the balance, withdraw() leaves the balance untouched. Then, implement a toString method that returns a string with the account number and balance, properly labeled. The savingsAccount class This class inherits from Account and adds an apr property, which is the annual percentage rate for interest. Write a no-argument constructor that sets the account number, balanace, and APR to zero. Write a three-argument constructor that takes an account number, balance, and interest rate as a decimal. Add a getter and setter method for apr. The setter should leave the APR untouched if given a negative value. Modify toString) to include the interest rate. Write a calculateInterest) method that returns the current balance times the annual interest rate The creditCardAccount Class This class inherits from Account and adds an apr property, which is the annual interest rate charged on the balance. It also hasa creditlinit property (double) which gives the credit limit for the card. Write a no-argument constructor that sets all the properties to zero. Write a four-argument constructor that takes an account number, balance, interest rate as a decimal, and credit limit. Override the withdraw) function so that you can have a negative balance. If a withdrawal would push you over the credit limit, leave the balance untouched. Add getters and setters for apr and creditlimit, leaving them untouched if the setter is given a negative value. Modify toString to include the interest rate and credit limit. Add a calculatePayment() method that returns zero if the balanoe is positive and the minimum of 20 and (apr/12)-balance)) if the balance is negative. The Test Program Write a program named TestAccounts Account objects: that creates an array of five An Account number 1066 with a balance of $7,500. . A SavingsAccount number 30507 with a balance of $4,500 and an APR of 1.5% A CreditCardAccount number 51782737 with a balance of $7,000.00, APR of 8%, and credit limit of $1000.00 A CreditCardAccount number 629553328 with a balance of $1.500.00, an APR of 7.5%, and a credit limit of $5,000 A CreditcardAccount number 4977201043 with a balance of zero, an APR of 7%, and a credit limit of $3,000 Your program will use a loop to do the following for each account: . Deposit $2,134.00 . Withdraw $4,782.00 Print the account status using toString The program will then print the interest to be paid for the savings account and the monthly payment due for the credit card accounts.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started