In Java:
DATA TYPE CLASS
Create one data type class Account_yourLastName that hold the information of an account such as accountNumber (String), name (String), address (String), balance (float), interestRate(float) and beside the no-argument constructor, parameterized constructor, the class has method openNewAccount, method checkCurrentBalance, method deposit, method withdrawal, method changeInterestRate
I have Implemented BankService_Smith.java file which provide various services for the bank account by creating object of Account_Smith class and calling various methods of Account_Smith class.
Account_Smith Class:-
In this class, we have no-rg constructor but its body is empty because when we create the objevct of Account_Smith class using no-arg construcotr then the all data members of Account_Smith class intialize with its default value by automatically that's why no-arg construcotor does not have body.
class Account_Smith{
// store account number
String accountNumber;
// store name of account holder
String name;
// store address of account holder
String address;
// store account balance
float balance;
// store interest rate
float interestRate;
// no- argument constructor
public Account_Smith(){
/*
When constructor call then
all the members intialize with its
default value automatically.
*/
}
// parameterized constructor
public Account_Smith(String accountNumber, String name, String address, float balance, float interestRate) {
this.accountNumber = accountNumber;
this.name = name;
this.address = address;
this.balance = balance;
this.interestRate = interestRate;
}
public void openAccount(){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("NEW ACCOUNT");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.println("Account Name:\t\t"+name);
System.out.println("Address:\t\t"+address);
System.out.println("Interest Rate:\t\t"+interestRate+"%");
System.out.printf("Start Balance:\t\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}
public void checkCurrentBalance(){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("CHECK CURRENT BALANCE");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.printf("Start Balance:\t\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}
public void deposit(float amount){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("DEPOSIT");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.printf("Balance:\t\t%.2f\n", balance);
System.out.printf("Deposit:\t\t%.2f\n", amount);
// deposit the amount into the account
balance += amount;
System.out.printf("Current Balance:\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}
public void withdraw(float withdrawableAmount){
// check valid amount or not
float bal = balance - withdrawableAmount;
if(bal >= 100){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("WITHDRAW");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.printf("Balance:\t\t%.2f\n", balance);
System.out.printf("Withdraw:\t\t%.2f\n", withdrawableAmount);
// withdraw the balance from the account
balance = bal;
System.out.printf("Current Balance:\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}else{
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("WITHDRAW");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.printf("Balance:\t\t%.2f\n", balance);
System.out.printf("Withdraw:\t\t%.2f - denied\n", withdrawableAmount);
System.out.printf("Current Balance:\t%.2f\n", balance);
System.out.println("\n-----------------------------------------------");
}
}
public void changeInterestRate(float newIntersetRate){
// modify interest Rate
interestRate = newIntersetRate;
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("CHANGE INTEREST RATE");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.println("Interest Rate:\t\t"+interestRate+"%");
System.out.println("-----------------------------------------------");
}
public void bankStatement(){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("BANK STATEMENT");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.println("Account Name:\t\t"+name);
System.out.println("Address:\t\t"+address);
System.out.println("Interest Rate:\t\t"+interestRate+"%");
System.out.printf("Balance:\t\t%.2f\n", balance);
// calculate balance with updated interest Rate
balance = balance + (balance * ((float)interestRate/100));
System.out.printf("New Balance:\t\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}
}
Here, I attached BankService_Smith.java file which provide menu to the user and user can perform any task by selecting appropriate task number.
BankService_Smith.java file:-
import java.util.Scanner;
class Account_Smith{
// store account number
String accountNumber;
// store name of account holder
String name;
// store address of account holder
String address;
// store account balance
float balance;
// store interest rate
float interestRate;
// no-argument constructor
public Account_Smith(){
/*
When constructor call then
all the members intialize with its
default value automatically.
*/
}
// parameterized constructor
public Account_Smith(String accountNumber, String name, String address, float balance, float interestRate) {
this.accountNumber = accountNumber;
this.name = name;
this.address = address;
this.balance = balance;
this.interestRate = interestRate;
}
public void openAccount(){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("NEW ACCOUNT");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.println("Account Name:\t\t"+name);
System.out.println("Address:\t\t"+address);
System.out.println("Interest Rate:\t\t"+interestRate+"%");
System.out.printf("Start Balance:\t\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}
public void checkCurrentBalance(){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("CHECK CURRENT BALANCE");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.printf("Start Balance:\t\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}
public void deposit(float amount){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("DEPOSIT");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.printf("Balance:\t\t%.2f\n", balance);
System.out.printf("Deposit:\t\t%.2f\n", amount);
// deposit the amount into the account
balance += amount;
System.out.printf("Current Balance:\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}
public void withdraw(float withdrawableAmount){
// check valid amount or not
float bal = balance - withdrawableAmount;
if(bal >= 100){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("WITHDRAW");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.printf("Balance:\t\t%.2f\n", balance);
System.out.printf("Withdraw:\t\t%.2f\n", withdrawableAmount);
// withdraw the balance from the account
balance = bal;
System.out.printf("Current Balance:\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}else{
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("WITHDRAW");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.printf("Balance:\t\t%.2f\n", balance);
System.out.printf("Withdraw:\t\t%.2f - denied\n", withdrawableAmount);
System.out.printf("Current Balance:\t%.2f\n", balance);
System.out.println("\n-----------------------------------------------");
}
}
public void changeInterestRate(float newIntersetRate){
// modify interest Rate
interestRate = newIntersetRate;
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("CHANGE INTEREST RATE");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.println("Interest Rate:\t\t"+interestRate+"%");
System.out.println("-----------------------------------------------");
}
public void bankStatement(){
System.out.println("ONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("BANK STATEMENT");
System.out.println("Account Number:\t\t"+accountNumber);
System.out.println("Account Name:\t\t"+name);
System.out.println("Address:\t\t"+address);
System.out.println("Interest Rate:\t\t"+interestRate+"%");
System.out.printf("Balance:\t\t%.2f\n", balance);
// calculate balance with updated interest Rate
balance = balance + (balance * ((float)interestRate/100));
System.out.printf("New Balance:\t\t%.2f", balance);
System.out.println("\n-----------------------------------------------");
}
}
// This class represents bank Service functionalities
public class BankService_Smith {
public static void main(String[] args) {
// create an object of Scanner class for user input
Scanner sc = new Scanner(System.in);
// declare object of Account_Smith class
Account_Smith account = null;
int ch = 0;
do{
System.out.println("\nONLINE BANK - JAMES SMITH");
System.out.println("-----------------------------------------------");
System.out.println("1. Open New Account");
System.out.println("2. Check Current Balance");
System.out.println("3. Deposit");
System.out.println("4. Withdrawal");
System.out.println("5. Change Interest Rate");
System.out.println("6. Bank Statement");
System.out.println("0. Exit");
// get the user input from the user
System.out.print("\nEnter your choice: ");
ch = sc.nextInt();
sc.nextLine();
switch(ch){
case 1 :
// get the Account number from the user
System.out.print("Enter Account number: ");
String accountNumber = sc.nextLine();
// get the name from the user
System.out.print("Enter Account Name: ");
String name = sc.nextLine();
// get the address from the user
System.out.print("Enter Address: ");
String address = sc.nextLine();
// get the interest rate from the user
System.out.print("Enter Interest Rate: ");
float interestRate = sc.nextFloat();
// get the balance from the user
System.out.print("Enter Balance: ");
float balance = sc.nextFloat();
sc.nextLine();
// intialize the account object with above all the values
account = new Account_Smith(accountNumber, name, address, balance, interestRate);
// now call the openAccount() method using Account_Smith class
account.openAccount();
break;
case 2:
// check whether account is opened or not?
if(account == null){
System.out.println("Open New Account before selecting this task");
}else{
// call the checkCurrentBalance() method for checking current balance of Account
account.checkCurrentBalance();
}
break;
case 3:
// check whether account is opened or not?
if(account == null){
System.out.println("Open New Account before selecting this task");
}else{
// get the deposit amount from the user
System.out.print("Please enter deposit amount : ");
float depositAmount = sc.nextFloat();
// call the deposit() method for depositing amount to the account
account.deposit(depositAmount);
sc.nextLine();
}
break;
case 4:
// check whether account is opened or not?
if(account == null){
System.out.println("Open New Account before selecting this task");
}else{
// get the withdraw amount from the user
System.out.print("Please enter amount for withdraw : ");
float withdrawableAmount = sc.nextFloat();
// call the withdraw(amount) method for withdrawing amount to the account
account.withdraw(withdrawableAmount);
sc.nextLine();
}
break;
case 5:
// check whether account is opened or not?
if(account == null){
System.out.println("Open New Account before selecting this task");
}else{
// get the interest rate from the user
System.out.print("Please enter interest rate : ");
float newInterestRate = sc.nextFloat();
// call the changeInterestRate(newInterestRate) method for updating Interest Rate
account.changeInterestRate(newInterestRate);
sc.nextLine();
}
break;
case 6:
// check whether account is opened or not?
if(account == null){
System.out.println("Open New Account before selecting this task");
}else{
// call banStatement() method for printing bank statement
account.bankStatement();
}
break;
case 0:
// exit from the menu and program will terminate
break;
default:
System.out.println("\nPlease enter valid task number\n");
}
}while(ch != 0);
}
}
Output:-
1> When user enter task(2 to 6) number before opening account.
2> When user opening an account.
3> When user check current balance.
4> When user deposit amount to the account.
5> When user withdraw invalid amount for withdraw process.
6> When user withdraw valid amount for withdraw process.
7> When user change the interest rate.
8> When user want to display Bank statement.
9> When user enter invalid task number.
I hope you will understand the Account_smith class and driver class.
Do you feel needful and useful then please upvote me.
Thank you.
In Java: DATA TYPE CLASS Create one data type class Account_yourLastName that hold the information of...
LAB1 PART 1 FOR THE DATA TYPE CLASS: If you do not have UML of class Account_yourLastName, you should do that first Basesd on the UML, provide the code of data type class Account_yourLastName to hold the information of an account with account number (String), name (String), balance (double), with no-argument constructor, parameter constructor Also, define some methods to handle the tasks: open account, check current balance, deposit, withdraw, and print monthly statement. At the end of each task we...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
Write a Java class called BankAccount (Parts of the code is given below), which has two fields name (String) and balance (double), two constructors and five methods getName(), getBalance(), deposit (double amount), withdraw(double amount) and toString(). The first constructor should initialize name to null and balance to 0. The second constructor initializes name and balance to the parameters passed. deposit method deposits the amount to the account causing the current balance to increase, withdraw method withdraws the amount causing the...
Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...
*Step1: -Create UML of data type classes: reuse from lab3 for class Account, CheckingAccount and SavingAccount -Read the requirement of each part; write the pseudo-code in a word document by listing the step by step what you suppose to do in main() and then save it with the name as Lab4_pseudoCode_yourLastName *Step2: -start editor eClipse, create the project→project name: FA2019_LAB4PART1_yourLastName(part1) OR FA2019_LAB4PART2_yourLastName (part2) -add data type classes (You can use these classes from lab3) Account_yourLastName.java CheckingAccount_yourLastName.java SavingAccount_yourLastName.java -Add data structure...
Requirements: Your Java class names must follow the names specified above. Note that they are case sensitive. See our template below. BankAccount: an abstract class. SavingAccount: a concrete class that extends BankAccount. o The constructor takes client's firstname, lastname and social security number. o The constructor should generate a random 6-digit number as the user account number. o The initial balance is 0 and the annual interest rate is fixed at 1.0% (0.01).o The withdraw method signature...
The program needs to be in python : First, create a BankAccount class. Your class should support the following methods: class BankAccount (object): """Bank Account protected by a pin number.""" def (self, pin) : init "n"Initial account balance is 0 and pin is 'pin'."" self.balance - 0 self.pin pin def deposit (self, pin, amount): """Increment account balance by amount and return new balance.""" def withdraw (self, pin, amount): """Decrement account balance by amount and return amount withdrawn.""" def get balance...
he class definition for a Hank Account class, contains the following private data nembers: the name, account number (both are character arrays of 30 elements each) alance, and interest rate Cbolth are double). It also have the following public member unctions Bank AccountO: This function is the default constructor. deposito: subsequently adjusts the balance. (balance- balance + amt) withdrawo: This function is passed an amount to withdraw and subsequently adjusts the balance. (balance balance- amt). cale interestO: This function calculates...
Design a class named BankAccount that contains: 1. A private int data field named accountId for the account. 2. A private double data field named accountBalance for the account (default 0). 3. A private double data field named annualInterestRate that stores the current interest rate (default 0). Assume all accounts have the same interest rate. 4. A private Date data field named dateCreated that stores the date when the account was created. 5. A private int data field named numberOfDeposits...
9.7 (The Account class) Design a class named Account that contains: • A private int data field named id for the account (default o). • A private double data field named balance for the account (default o). • A private double data field named annualInterestRate that stores the current interest rate (default o). Assume that all accounts have the same interest rate. • A private Date data field named dateCreated that stores the date when the account was created. •...