Hey neighbor, can you lend some Hammers?

Hey neighbor, can you lend some Hammers?

import java.util.Date;

public class AccountProblem {
    public static void main(String[] args) {
//create an instance  object of class Stock
        Account myAccount = new Account(1122, 20000.00, 0.045);
        myAccount.withdraw(2500.00);
        myAccount.deposit(3000.00);
//display balance, monthly interest and date of account
        System.out.println("Balance: " + myAccount.balance);
        System.out.println("Monthly Interest: " + myAccount.getMonthlyInterestRate());
        System.out.println("Account created on: " + myAccount.dateCreated);
    }
}

class Account {
//define var1, var2
    int id;
    double balance;
    double annualInterestRate;
    Date dateCreated;
//no arg constructer
    Account() {
        id = 0;
        balance = 0.0;
        annualInterestRate = 0.0;
    }
//constructor with specific id and initial balance
    Account(int newId, double newBalance) {
        id = newId;
        balance = newBalance;
    }
    Account(int newId, double newBalance, double newAnnualInterestRate) {
        id = newId;
        balance = newBalance;
        annualInterestRate = newAnnualInterestRate;
    }
//accessor/mutator methods for id, balance, and annualInterestRate
    public int getId() {
        return id;
    }
    public double getBalance() {
        return balance;
    }
    public double getAnnualInterestRate() {
        return annualInterestRate;
    }
    public void setId(int newId) {
        id = newId;
    }
    public void setBalance(double newBalance) {
        balance = newBalance;
    }
    public void setAnnualInterestRate(double newAnnualInterestRate) {
        annualInterestRate = newAnnualInterestRate;
    }
//accessor method for dateCreated
    public void setDateCreated(Date newDateCreated) {
        dateCreated = newDateCreated;
    }
//define method getMonthlyInterestRate
    double getMonthlyInterestRate() {
        return annualInterestRate/12;
    }
//define method withdraw
    double withdraw(double amount) {
        return balance -= amount;
    }   
//define method deposit
    double deposit(double amount) {
        return balance += amount;
    }
}
View Answers









Related Tutorials/Questions & Answers:
Hey neighbor, can you lend some Hammers?
Hey neighbor, can you lend some Hammers?
Advertisements
Can you give me some good factory pattern examples?
ModuleNotFoundError: No module named 'Hey'
ModuleNotFoundError: No module named 'hey_dl'
ModuleNotFoundError: No module named 'hey_rexec'
ModuleNotFoundError: No module named 'hey_april'
ModuleNotFoundError: No module named 'hey_pgsqlexec'
Please can you help
can you explain ?
can some help out on wrting this program. - Java Beginners
Can you correct this codes?
What Systems you can migrate to Cloud?
Can you get a job with Dataquest?
Can you make AI in Python?
Can you build AI with Python?
Can you help me with applet?
i am confused here on what to write can some 1 help out here - Java Beginners
Hey Guys really need to learn - Java Beginners
How many qusetions can you ask?
how can you calculate you your age in daies??
Can you create an object of an abstract class?
ModuleNotFoundError: No module named 'can-you-guess'
how can you say java is secure
Can you provide me Hibernate configuration tutorial?
Can you instantiate the Math class? - Java Beginners
Can you become a data scientist without a degree?
How can you tell a fake data scientist?
Can you work part time as a data scientist?
Can you work as a data scientist from home?
Can you teach yourself machine learning?
Can you learn python in 2 days?
Can you tell me how it worked?
can you check below code if any erors
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
i have created interface program for simple arithmetic operation but its show some error can i get reason and mistakes
ModuleNotFoundError: No module named 'some'
ModuleNotFoundError: No module named 'some'
Just Got An iPad? - The Range Of Protective Cases You Can Choose From
Can you suggest any good book to learn struts
Can you give few examples of final classes defined in Java API?
Can you give me Hibernate one to one example?
Can you give me a simple Hibernate Sessionfactory example?
How can you add elements of two arrayLists in java?
Can you go from data analyst to data scientist?
How can you handle form in Spring 3.2 MVC?
programming language definition you can learn apart from java
Hey - Java Beginners
Your competitor presses you to reveal some confidential information about your current or previous employer.
Need some help urgently

Ads