Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write the full code! Java language Write a part of the implementation for

ID: 3874257 • Letter: P

Question

Please write the full code!

Java language Write a part of the implementation for the class BankAccount. It holds the deposit and partial transfer on the account. You have to define one constructer, the method double returnDeposit) which holds the current balance, the method void addIn (double amount) which adds the amount of money to the account, the method boolean takeout double amount) which takes money out of the account if there is enough money on the account (returns true), otherwise does nothing (returns false). The method transactions), which runs once a month and lowers the deposit. The rules are that the first 5 transactions are free, after that are taken 10kr for each transaction.The method has to reset the number of transactions on the account. public class BankAccount f double deposit; double numTransactions; // constructer: //the method returnDeposit: //the method addIn: //the method takeOut: //the method transactions:

Explanation / Answer

import java.util.*;
import java.lang.*;
import java.io.*;
public class BankAccount
{
double deposit;
double numTransaction;
BankAccount()
{
deposit=1000;//Initial balance is 1000
numTransaction=0;//initial transaction no. is 0
}
double returnDeposit()//this function returns the balance of the account
{
return deposit;
}
public void addIn(double amount)//it adds the amount to be deposited in the account
{
deposit=deposit+amount;
numTransaction++;//if amount gets deposited,it is counted as successful transaction and hence we increment it by one
}
public boolean takeOut(double amount)//it update the balance after withdrawal if there is sufficient money in the account
{
if(deposit>=amount)//checking if there is sufficient money in the account
{
deposit=deposit-amount;
numTransaction++;/if amount gets withdrwan,it is counted as successful transaction and hence we increment it by one
return true;
}
else
{
numTransaction++;
return false;
}
}
public void transaction()
{
if(numTransaction>=5)
{
deposit=deposit+(numTransaction-5)*10;
numTransaction=0;
}
}
public static void main (String[] args) throws java.lang.Exception
{
BankAccount ob=new BankAccount();
Scanner sc=new Scanner(System.in);
System.out.println("Initial balance ="+ob.returnDeposit());

//Transaction within a month
double amountDeposit1=sc.nextDouble();
ob.addIn(amountDeposit1);
double amountWithdraw1=sc.nextDouble();
ob.takeOut(amountWithdraw1);
double amountDeposit2=sc.nextDouble();
ob.addIn(amountDeposit2);
double amountDeposit3=sc.nextDouble();
ob.addIn(amountDeposit3);
double amountWithdraw2=sc.nextDouble();
ob.takeOut(amountWithdraw2);
ob.transaction();
System.out.println("Current balance after a month="+ob.returnDeposit());
    }
}

Sample Input:

200
400
500
300
300

Sample Output: