use java please 2. Modify the BankAccount class previously created to add two me
ID: 3705255 • Letter: U
Question
use java please
Explanation / Answer
BankAccount.java
package banktest;
import java.util.Scanner;
public class BankAccount {
public float amount,w_amount;
public void deposit()
{
System.out.println("Please enter amount to deposit:");
Scanner sc1 = new Scanner(System.in);
amount = sc1.nextFloat();
System.out.println("The amount deposited by you is:" + amount);
}
public void withdrawal()
{
System.out.println("Please enter the withdrawal amount:");
Scanner sc2 = new Scanner(System.in);
w_amount = sc2.nextFloat();
amount = amount - w_amount;
System.out.println("Your withdrawal amount is:" + w_amount);
System.out.println("Your remaining deposit amount is:" + amount);
}
}
_____________________________________________________________________________________________
Saving_account.java
package banktest;
import java.util.Scanner;
public class Saving_account extends BankAccount {
public float i_amount,total_deposit;
public void deposit()
{
System.out.println("Please enter amount to deposit:");
Scanner sc1 = new Scanner(System.in);
amount = sc1.nextFloat();
i_amount = (float) (0.01 * amount);
total_deposit = amount + i_amount;
System.out.println("Your deposit amount is:" + amount);
System.out.println("Interest applied to the deposit amount:" + i_amount);
System.out.println("Your total deposit is:" + total_deposit);
}
public void withdrawal()
{
System.out.println("Withdrawal is not allowed with Saving account");
}
}
_______________________________________________________________________________________________
Checking_account.java
package banktest;
import java.util.Scanner;
public class Checking_account extends BankAccount{
public float withdrawing_fee=1,total_wamount;
public void withdrawal()
{
System.out.println("Please enter the withdrawal amount:");
Scanner sc2 = new Scanner(System.in);
w_amount = sc2.nextFloat();
total_wamount = w_amount + withdrawing_fee;
amount = amount - total_wamount;
System.out.println("Your withdrawal amount is:" + w_amount);
System.out.println("Withdrawing fees applied is:" + withdrawing_fee);
System.out.println("Total withdrawal amount is:" + total_wamount);
System.out.println("Your remaining deposit amount is:" + amount);
}
}
______________________________________________________________________________________________
BankTest.java
package banktest;
public class BankTest {
public static void main(String[] args) {
System.out.println("Deposit in a basic Bank Account");
BankAccount ba = new BankAccount();
ba.deposit();
ba.withdrawal();
System.out.println("_______________________________________________________");
System.out.println("Deposit in a Savings Account");
Saving_account sa = new Saving_account();
sa.deposit();
sa.withdrawal();
System.out.println("________________________________________________________");
System.out.println("Deposit in a Checking Account");
Checking_account ca = new Checking_account();
ca.deposit();
ca.withdrawal();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.