I dont have any transaction class information so i have created one of my choice with single description field.If you have transaction class you can change the setter in the withdraw and deposit methods
Account class:
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class Account {
private int accId;
private String custName;
private double accBalance;
private double interestRate;
private Date createdAt;
private List<Transaction> transList=new ArrayList<>();
public Account() {
accId=0;
custName="";
accBalance=0.0;
interestRate=0;
Date dt=new java.util.Date();
createdAt=dt;
}
public Account(int id,String name,double balance,double rate){
accBalance=balance;
accId=id;
custName=name;
interestRate=rate;
Date dt=new java.util.Date();
createdAt=dt;
}
public int getAccId() {
return accId;
}
public void setAccId(int accId) {
this.accId = accId;
}
public String getCustName() {
return custName;
}
public void setCustName(String custName) {
this.custName = custName;
}
public double getAccBalance() {
return accBalance;
}
public void setAccBalance(double accBalance) {
this.accBalance = accBalance;
}
public double getInterestRate() {
return interestRate;
}
public void setInterestRate(double interestRate) {
this.interestRate = interestRate;
}
public Date getCreatedAt() {
return createdAt;
}
public void setCreatedAt(Date createdAt) {
this.createdAt = createdAt;
}
public List<Transaction> getTransList() {
return transList;
}
public void setTransList(List<Transaction> transList) {
this.transList = transList;
}
public double getMonthlyInterest(){
double inteEarned=this.accBalance*(this.interestRate/1200);
return inteEarned;
}
public void withDraw(double amt){
this.accBalance=this.accBalance-amt;
Transaction t=new Transaction();
t.setDesc("withdrawn amount of "+amt+" from "+accId+" remaining balance is "+accBalance);
transList.add(t);
}
public void deposit(double amtDepo){
this.accBalance=this.accBalance+amtDepo;
Transaction t=new Transaction();
t.setDesc("deposited amount of "+amtDepo+" to "+accId+" new balance is "+accBalance);
transList.add(t);
}
}
Transaction class;
public class Transaction {
private String desc;
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
}
Tester class:
public class AccountTester {
public static void main(String[] args) {
// TODO Auto-generated method stub
Account acc=new Account(1122,"George", 1000,1.5);
acc.deposit(30);//depositing 30,40,50$
acc.deposit(40);
acc.deposit(50);
acc.withDraw(5);//withdrwaing 5,4,2$
acc.withDraw(4);
acc.withDraw(2);
System.out.println("Account summary");
System.out.println("------------------------");
System.out.println("Account holders name : "+acc.getCustName());
System.out.println("Annual interest rate : "+acc.getInterestRate());
System.out.println("Account Balance : "+acc.getAccBalance());
System.out.println("Monthly interest earned : "+acc.getMonthlyInterest());
System.out.println("Transactions done");
for(Transaction t:acc.getTransList()){
System.out.println(t.getDesc());
}
}
}
Expected output:
![貝Console X «terminated> Accountlester [Java Application] C:\Program FilesUavarel .8.0-111\binjavaw.exe (Mar 20 Account summar](http://img.homeworklib.com/questions/f8389100-bcc7-11ea-b250-ddfcded8ba08.png?x-oss-process=image/resize,w_560)
Be sure to submit homework via Canvas, not email. Ask questions via email or Canvas inbox....
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...
JAVA LANG PACKAGE Create a NetBeans project for this activity. 1: Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes. Now override the to String() method. 2: Create a class with the main method and create an instance of the class that you created 3: Create an instance of the string in your test class and assign a value. 4: Now create an String...
Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...
Create a NetBeans project called "Question 1". Then create a public class inside question1 package called Author according to the following information (Make sure to check the UML diagram) Author -name:String -email:String -gender:char +Author(name:String, email:String, gender:char) +getName():String +getEmail):String +setEmail (email:String):void +getGender():char +tostring ):String . Three private instance variables: name (String), email (String), and gender (char of either 'm' or 'f'): One constructor to initialize the name, email and gender with the given values . Getters and setters: get Name (), getEmail() and getGender (). There are no setters for name and...
signature 1. Create a new NetBeans Java project. The name of the project has to be the first part of the name you write on the test sheet. The name of the package has to be testo You can chose a name for the Main class. (2p) 2. Create a new class named Address in the test Two package. This class has the following attributes: city: String-the name of the city zip: int - the ZIP code of the city...
Write a C++ program for the instructions below. Please
read the instructions carefully and make sure they are followed
correctly.
and please put comment with code!
Problem:2 1. Class Student Create a "Hello C++! I love CS52" Program 10 points Create a program that simply outputs the text Hello C++!I love CS52" when you run it. This can be done by using cout object in the main function. 2. Create a Class and an Object In the same file as...
Hi, I need help with this Java activity. The requirements are: 1. Create a NetBeans project for this activity. 2. Create a new class with attributes name and address. Both data type will be String. Create a constructor and assign the parameters to the attributes. 3. Create a class with the main method and create an instance of the class that you created in Test Stem 1. 4. Create an instance of the string in your test class and assign...
Please submit a .cpp file or upload zip if you have more than one file before the time up. No library function is allowed. ***The code must contain your name and has proper format. Create a class named CupCake. It contains: • Has private instance variables 1. egg 2. butter 3. baking powder 4. sugar 5. flour 6. milk • All members must have public methods: getter() and setter(). • A constructor - a default constructor with no arguments. The...
I was wondering how do I add an event to the buttons for
show an image on the menu bar by using lamda? 5C
Create a JavaFX project in Eclipse with a name like ex2 or exercise2. Use the default package application. If you want, you may refactor it. Use the default JavaFX class (a source file) named Main.java. Again, you may change the name of the source file (class file, eventually) by refactoring. Download the runnable JAR file named...
Visual C#
Homework 2
You are to write a program which will create a class called
Student
Each student has a name age height and weight. These variables
should be declared as private.
Create the correct constructors and functions.
In the main, you will create 5 students.
Input the data for the 5 students from a file which already
has information in it. Name the file “Information.txt”.
After setting up all the data, it is time to sort based on...