I UPVOTE ALL ANSWERS, thank you for your work. Please follow all instructions ex
ID: 3714896 • Letter: I
Question
I UPVOTE ALL ANSWERS, thank you for your work. Please follow all instructions exactly, I will upvote.
This is the transaction class referenced in the instructions to use.
The Transaction class is as follows:
Transaction.java
import java.util.Date;
public class Transaction {
//Data members
private Date date;
private char type;
private double amount,balance;
private String description;
//Parametrized constructor to initialize fields
public Transaction(char type, String description,double amount, double balance) {
this.date = new Date();
this.type = type;
this.amount = amount;
this.balance = balance;
this.description = description;
}
//Accessor methods
public Date getDate() {
return date;
}
public char getType() {
return type;
}
public double getAmount() {
return amount;
}
public double getBalance() {
return balance;
}
public String getDescription() {
return description;
}
public String toString(){
String typeOfTrans;
//If type is D, its deposit else withdrawl
if(type=='D'){
typeOfTrans="Deposit";
}else{
typeOfTrans="Withdrawl";
}
//Return string contain details of transaction
return "Type of Transaction: "+typeOfTrans+" "+
"Date of Tansaction: "+date+" "+
"Description: "+description+" "+
"Balance: "+balance+" "+
"Amount: "+amount+" ";
}
}
This is the transaction test class, I do not believe you need it, believe you only need the Transaction class to do the required but here it is in case:
public class TransactionTest {
public static void main(String[] args) {
//Create two objects of transaction
Transaction t1=new Transaction('D',"Babysitting Income",50,1050);
Transaction t2=new Transaction('W',"Tennis Fee",30,1020);
//Print them
System.out.println(t1);
System.out.println(t2);
}
}
You are required to create a NetBeans project modeled arter a banking situation. First, create the projec named as HWSYourFirstNameLastName. Check to create the main class, which will create a package under Source Packages, named after your project name, and open the main class containing the main method. Next, copy and paste the Transaction class from your HW4 into this package using NetBeans' Refactor feature. If not using Refactor, just copy and paste the Transaction class into this package, then open the Transaction class and update its first line of code by changing the package name to its current package name. For this project, you are required to create two classes other than the Transaction class: an Account class (whereas an account may incur multiple transactions) and the main class (containing the main method). Please closely follow the requirements below. Requirements for the Account class: You need to create the Account class as an independent file in the same package of your main class Class data fields: A private data field of int data type, representing the id of the account. A private data field of String data type, representing the name of the customer A private data field of double data type, representing the balance of the account. A private data field of double data type, representing the annual interest rate. Key assumptions: (1) all accounts created following this class construct share the same interest rate. (2) While the annual interest rate is a percentage, e, g., 4.5%, but for simplicity users will just enter the double number as 4.5 (not 0.045). Therefore, you, the code developer, need to divide the annual interest rate by 100 whenever you use it in a calculation A private data field of Date data type, representing the account creating date. A private data field of ArrayList data type, representing a list of transactions for the account. Each element of this ArrayList must be an instance of the Transaction class defined in HW4 (the Transaction class has been copied into the current package)Explanation / Answer
The code is as follows:
/*package whatever //do not write package name here */
import java.io.*;
class Account {
private int id;
private String name;
private double balance;
private double interest;
private Date date;
private<Transaction> list;
Account()
{
id = 1;
name = "John";
balance = 10.54;
interest = 4.5;
//date = 20-4-18;
}
Account(int i, String n, double bal, double inter)
{
id = i;
name = n;
balance = bal;
interest = inter;
}
void getid()
{
return id;
}
void getbal()
{
return bal;
}
void getname()
{
return name;
}
void setid(int i)
{
id = i;
}
void setbal(int bal)
{
balance = bal;
}
void setname(string n)
{
name = n;
}
double getmonthlyinterest()
{
return (interest*bal)/(1200);
}
public static void main (String[] args) {
Account obj = new Account(1122, "George", 1000, 1.5);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.