java code:
package accountdemo;
import java.util.Date;
import java.util.Scanner;
//account class
class BankAccount
{
private int id;
private double balance;
private Date dateCreated;
private static int nextId=1;
BankAccount()
{}
//constructor
BankAccount(double balance){
id=nextId;
this.balance=balance;
nextId++;
dateCreated=new Date();
}
//getter
public int getId()
{
return id;
}
public double getBalance()
{
return balance;
}
public Date getDateCreated()
{
return dateCreated;
}
//withdraw
public void withdraw(double amount)
{
balance -= amount;
}
//deposit
public void deposit(double amount)
{
balance += amount;
}
//return string
public String toString()
{
return "Account ID: "+id +
" Balance: " + balance +
" Date Created: "+ dateCreated;
}
}
//CheckingAccount class
class CheckingAccount extends BankAccount
{
double fee;
int withdrawals;
//constructor
public CheckingAccount(double balance,double fee) {
//super(balance-fee);
//this.fee=fee;
}
public CheckingAccount() {
withdrawals=0;
}
public void withdraw(double amount)
{
final int FREE_WITHDRAWALS =3;
final int WITHDRAWALS_FEE =1;
if(super.getBalance()>amount)
super.withdraw(amount);
else
{
withdrawals++;
if(withdrawals<3)
super.withdraw(20);
if(withdrawals>2){
super.withdraw(30);
if(withdrawals>1)
super.withdraw(WITHDRAWALS_FEE);
}
}
}
//deduct fee
public void deductFee(double fee)
{
this.fee=fee;
}
//setter
public void setFee(double fee)
{
this.fee=fee;
}
//getter
public double getFee()
{
return fee;
}
//return string
public String toString()
{
return (super.toString()+ " Monthly Fee: "+fee);
}
}
//SavingsAccount class
class SavingsAccount extends BankAccount
{
double interest;
//constructor
public SavingsAccount(double balance,double interest) {
super(balance+(balance*interest/100));
this.interest=interest/100;
}
//setter
public void setInterest(double interest)
{
this.interest=interest;
}
//getter
public double getInterest()
{
return interest;
}
//interest caluclate function
public double calculateInterest()
{
return interest/100;
}
//rerurn string
public String toString()
{
return (super.toString()+ " Interest Rate: "+interest);
}
}
public class AccountDemo {
public static void main(String[] args) {
final int ACCOUNTS_SIZE =5;
BankAccount[] accounts =new BankAccount[ACCOUNTS_SIZE];
for(int i=0; i<accounts.length; i++)
{
accounts[i]=new CheckingAccount();
}
int id;
double amount;
id=1;
amount =50.0;
accounts[id].deposit(500);
System.out.println("Account "+id+" balance =
"+accounts[id].getBalance()+"\n\n" );
System.out.println("Attempting to withdraw "+amount+" from Account
"+id);
accounts[id].withdraw(amount);
System.out.println("Account "+id+" balance = "+
accounts[id].getBalance());
amount =40;
System.out.println("\nAttempting to withdraw "+amount+" from
Account "+id);
accounts[id].withdraw(amount);
System.out.println("Account "+id+" balance = "+
accounts[id].getBalance());
amount =500;
System.out.println("\nAttempting to withdraw "+amount+" from
Account "+id);
accounts[id].withdraw(amount);
System.out.println("Account "+id+" balance = "+
accounts[id].getBalance());
amount =391;
System.out.println("\nAttempting to withdraw "+amount+" from
Account "+id);
accounts[id].withdraw(amount);
System.out.println("Account "+id+" balance = "+
accounts[id].getBalance());
amount =370;
System.out.println("\nAttempting to withdraw "+amount+" from
Account "+id);
accounts[id].withdraw(amount);
System.out.println("Account "+id+" balance = "+
accounts[id].getBalance());
}
}
output:
//for any clarification, please do comments
in java instructions Assignment 2 Complete Exercise E9.3 (checking account problem). What to turn in: A...
Use the Java codes below (Checking Account and Checking Account Demo), and work on these problems. You have to do both of your java codes based on the two provided Java codes. Create one method for depositing and one for withdrawing. The deposit method should have one parameter to indicate the amount to be deposited. You must make sure the amount to be deposited is positive. The withdraw method should have one parameter to indicate the amount to be withdrawn...
The Checking account is interest free and charges transaction fees. The first two monthly transactions are free. It charges a $3 fee for every extra transaction (deposit, withdrawal). The Gold account gives a fixed interest at 5% while the Regular account gives fixed interest at 6%, less a fixed charge of $10. Whenever a withdrawal from a Regular or a Checking account is attempted and the given value is higher than the account's current balance, only the money currently available...
code must be in java. Assignment 5 Purpose In this assignment, you will implement a class hierarchy in Java. Instructions The class hierarchy you will implement is shown below account Package Account manager Package SavingAccount CheckingAccount AccountManager The descriptions of each class and the corresponding members are provided below. Please note that the Visibility Modifiers (public, private and protected) are not specified and you must use the most appropriate modifiers Class AccountManager is a test main program. Create it so...
The objectives of this assignment are to: Further enhance your knowledge and skill in Java. Gain an understanding and experience with stacks. Gain further experience using generics. Continue to practice good programming techniques. Create a stack class named MyStack that stores generics with the methods shown below. Write a test program that thoroughly tests your stack implementation. void push(E item) push item onto top of stack E peek() return item on top of stack E pop() return item on top...
[JAVA] < Instruction> You are given two classes, BankAccount and ManageAccounts ManageAccounts is called a Driver class that uses BankAccount. associate a member to BankAcount that shows the Date and Time that Accounts is created. You may use a class Date. To find API on class Date, search for Date.java. Make sure to include date information to the method toString(). you must follow the instruction and Upload two java files. BankAccount.java and ManageAccounts.java. -------------------------------------------------------------------------- A Bank Account Class File Account.java...
You are to write a Java program using the following instructions to build a bank-ATM server system with sockets. A bank holds accounts that can have deposits, withdrawals, or retrievals of balance. The bank server provides the account for transactions when a client uses and ATM machine. The ATM asks for the type of transaction and the amount (if needed), then creates a socket connection to the bank to send the transaction for processing. The bank performs the transaction on...
need help with this assignment, please. Part 1 - Java program named MemoryCalculator In your Ubuntu VM (virtual machine), using terminal mode ONLY, do the following: Create the folder program2 In this folder place the text file located on my faculty website in Module 2 called RAMerrors (Do not rename this file, it has no extension.) It is down below. Ths is the file RAMErrors 3CDAEFFAD ABCDEFABC 7A0EDF301 1A00D0000 Each record in this file represents the location of an error...
Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account. --->Console Welcome to the Account application Starting Balances Checking: $1,000.00 Savings: $1,000.00 Enter the transactions for the month Withdrawal or deposit? (w/d): w Checking or savings? (c/s): c Amount?: 500 Continue? (y/n): y Withdrawal or deposit? (w/d): d Checking or savings? (c/s): s Amount?: 200 Continue? (y/n): n Monthly Payments and Fees Checking fee: $1.00 Savings...
pls write psuedocode write UML CODE ALSO example 3 files 1 for abstract 1 for bank account and 1 for savings accounts due in 12 hours Lab Assignment 4a Due: June 13th by 9:00 pm Complete the following Programming Assignment. Use good programming style and all the concepts previously covered. Submit the java files electronically through Canvas by the above due date in 1 Zip file Lab4.Zip. (This is from the chapter on Inheritance.) 9. BankAccount and SavingsAccount Classes Design...
Java Programming assignment. 1. Create a class called Square that takes a width parameter in the constructor. The Square class should have a draw() method that will draw the square on the screen. Create a class called TestSquare that will take width from the user, create an object of Square, and invoke the draw() method on the square object. Below is a UML diagram for the Square and Rectangle class: 3. Create a zip file that contains your Java programs....