Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

package Lab6; /** * * @author */ public interface AccountInterface { } /* * To change this license header, choose License Headers in Project Properties.

image text in transcribed

package Lab6;

/**

*

* @author

*/

public interface AccountInterface {

}

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Lab6;

/**

*

* @author

*/

public class Account implements AccountInterface{

private double balance;

private String name;

Account(){

}

Account(String name,double balance){

}

public String getName(){

}

public double getBalance(){

}

public void setName(String newName){

}

public void setBalance(double newBalance){

}

public double withdraw(double amount){

if(amount

}

else if((balance-amount)

}

else

return

}

public double deposit(double amount){

}

public void displayAccountInfo() {

}

public void balance() {

}

}

/*

* To change this license header, choose License Headers in Project Properties.

* To change this template file, choose Tools | Templates

* and open the template in the editor.

*/

package Lab6;

import java.util.Iterator;

import java.util.LinkedList;

import java.util.Scanner;

/**

*

* @

*/

public class TestAccount {

public static void main(String[] args) {

//put your account list based on linkedList in java here.

//add six customers account to your list here

Scanner sc= new Scanner(System.in);

System.out.println("Select a choice:");

System.out.println("1. Existing customer");

System.out.println("2. New customer");

System.out.println("3. Quit");

String str1=sc.next();

Account temp=null;

if(str1.equals("1")){

System.out.println("Enter your name: ");

String str2=sc.next();

for(Account acc: accountList){

if(acc.getName().compareTo(str2)==0)

{

temp=acc;

}

}

System.out.println("Would you like to: ");

System.out.println("1. Deposit ");

System.out.println("2. Withdraw ");

System.out.println("3. Display account info ");

System.out.println("4. Check balance ");

String str3=sc.next();

if(str3.equals("1")){

System.out.println("The balance before deposit: "+ temp.getBalance());

System.out.println("How much would you like to deposit?");

double deposit = sc.nextDouble();

temp.deposit(deposit);

System.out.println("The balance after deposit: "+ temp.getBalance());

}

else if (str3.equals("2")){

System.out.println("The balance before withdraw: "+ temp.getBalance());

System.out.println("How much would you like to withdraw?");

double withdraw = sc.nextDouble();

temp.withdraw(withdraw);

System.out.println("The balance after withdraw: "+ temp.getBalance());

}

else if (str3.equals("3")){

temp.displayAccountInfo();

}

else if (str3.equals("4"))

temp.balance();

else

System.out.println("Invalid");

}

/ew customer

else if(str1.equals("2")){

//add new user to arraylist

System.out.println("Enter your name: ");

String str4 = sc.next();

System.out.println("Enter initial balance: ");

double balance = sc.nextInt();

accountList.add(new Account(str4 , balance));

System.out.println("All account's info are displayed as follows: ");

for(Account acc: accountList){

System.out.println(acc.getName());

System.out.println(acc.getBalance());

}

}

else if(str1.equals("3")){

System.out.println("Thanks for using this bank!");

//flag = false;

}

else{

System.out.println("Invalid");

}

}

}

Java data structures, thanks!

Bank Account used LinkedList class in Java Instructions: A) Goal: using the existing LinkedList class in java to implement a simple bank account management system, where an existing customer can check his/her balance, perform deposit and withdraw activities and a new customer can open a new account. B) Task: 1) Design an interface named Accountlnteface that contains: (Points: 20/100) a. The accessor and mutator methods for balance, and name, i.e., getName(), getBalance(), setName(String newName) and setBalance(double newBalance) b. A method named withdraw that withdraws a specified amount from the account, i.e, withdraw(double amount) c. A method named deposit that deposits a specified amount to the account, i.e., deposit(double amount) 2) Design an account class to implement the above interface. In this class, you should include a default constructor with name ull and balance-00, and another constructor which can initialize the customer's name and balance (Points: 40/100) (Points: 40/100) 3) Write a TestAccount class that creates an accountList based on LinkedList in java add six customer's accounts into this list including name and initial balance info a. b. C) Procedure: 1. 2. 3. 4. 5. download the attached class TestAccount.java make the mentioned interface Implement the interface Make a linkedList in java to include six customer's info Run the TestAccount

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

More Books

Students also viewed these Databases questions

Question

Influences on Nonverbal Communication?

Answered: 1 week ago