import java.util.* //This class represents an Account. / /An Account has: //An account id //A balance //A date created //The static field, account Number is used to assign each //account an accountId starting with 1. public class Account private int accountId; private double balance private Date date_created private static int accountNumber = 1: 1Default counstructor. Creates object with a balance of 0 public Account ) date_created = new Date(); balance= 0; accountId = accountNumber; accountNumber++ } /Create an account with an initial balance public Account (double balance) date_created = new Date () this.balance balance; accountNumber; accountId = accountNumbert+; //Getters for each instance field below public int getAccountId () return account Id; public double getBalance ) return balance; } public Date getDateCreated ) return date_created; //Setters withdraw and deposit change the balance //Setters are not required for the dateCreated and accountId fields //since the fields cannot be changed public void withdraw (double amount) balance -= amount; } public void deposit (double amount) balance amount; } //This method returns a String representation of the Account object public String toString () { return "Account Id: Balance: balance + Date Created: date_created accountId } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Use the Java Class, Account.java, provided. Please do not rename or make any changes to this class. Do not turn in the Account class. Your program will be tested with the Account class provided.

Write a Java Program that meets the following requirements:
1. Write a Java class, rinoel_Bank.
2. At the beginning of the program include a comment with your name and a brief description of the program. Please include a short comment befor each method
3. The Bank class will have the following instance variables: 
a. An Array of Account objects that can hold 20 Accounts named, bank.
b. An int variable, numberOfAccounts which indicates the number of Account objects in the account array
4. The Bank class will have the following constructor:
a. A default/noargs constructor: 
i. It will create the Array of Account objects
ii. Set the numberOfAccounts to zero
b. One accessor method:
public int getNumberOfAccounts() //returns the numberOfAccounts
c. The following methods:
public void addAccount (Account a) 
 Adds Account object, a, to the Array of accounts
 Adds 1 to the numberOfAccounts
public void addAccount(double initBalance) 
 Creates a new Account using initBalance
 Adds the new Account to the Array of accounts
 Adds 1 to the numberOfAccounts
public double getTotalBalance() 
 Returns the sum of the balance of all the Account objects in the Array of
accounts
public Account getMaxBalance() 
 Returns the Account with the highest balance in the Array of accounts
d. A toString() method that returns a String representation of the Bank object in
the format shown in the sample output below. 
public String toString()

5. Write a test program, rinoel_TestBank.java 
which does the following:
a. Create a Bank object 
b. In a loop, repeat 5 times: 
i. Using a Scanner, prompt the user for the balance of an Account object.
ii. Call the addAccount method of the Bank to add an Account object to the
Array using the balance entered by the user. You can call either of the two addAccount methods of the Bank class.
c. At the end of the loop, print the Bank object. 
d. Using the methods of the Bank class, print the following in the format shown
below:
i. The total balance of all accounts in the Bank using the
getTotalBalance() method of the Bank class 
ii. The Account with the highest balance in the array of Accounts using the
getMaxBalance() method of the Bank class. 
e. The prompts and output should be formatted like the sample program running below. 

f. Readability and indentation: Code should be easy to read and properly indented. Variable names should be descriptive

 

Sample Program running
Enter a balance
100
Enter a balance
200
Enter a balance
300
Enter a balance
400
Enter a balance
500
The accounts in the Bank are:
Account ID: 1 Balance: 100.0 Date Created Sun Mar 20 10:18:17 EDT 2016
Account ID: 2 Balance: 200.0 Date Created Sun Mar 20 10:18:18 EDT 2016
Account ID: 3 Balance: 300.0 Date Created Sun Mar 20 10:18:19 EDT 2016
Account ID: 4 Balance: 400.0 Date Created Sun Mar 20 10:18:20 EDT 2016
Account ID: 5 Balance: 500.0 Date Created Sun Mar 20 10:18:22 EDT 2016
The total balance in the bank is 1500.0
The account with the highest balance in the bank is
Account ID: 5 Balance: 500.0 Date Created Sun Mar 20 10:18:22 EDT 2016

 

import java.util.*
//This class represents an Account.
/ /An Account has:
//An account id
//A balance
//A date created
//The static field, account Number is used to assign each
//account an accountId starting with 1.
public class Account
private int accountId;
private double balance
private Date date_created
private static int accountNumber
= 1:
1Default counstructor. Creates object with a balance of 0
public Account )
date_created = new Date();
balance= 0;
accountId =
accountNumber;
accountNumber++
}
/Create an account with an initial balance
public Account (double balance)
date_created = new Date ()
this.balance
balance;
accountNumber;
accountId =
accountNumbert+;
//Getters for each instance field below
public int getAccountId ()
return account Id;
public double getBalance )
return balance;
}
public Date getDateCreated )
return date_created;
//Setters withdraw and deposit change the balance
//Setters are not required for the dateCreated and accountId fields
//since the fields cannot be changed
public void withdraw (double amount)
balance -= amount;
}
public void deposit (double amount)
balance amount;
}
//This method returns a String representation of the Account object
public String toString () {
return "Account Id:
Balance:
balance +
Date Created:
date_created
accountId
}
}
Transcribed Image Text:import java.util.* //This class represents an Account. / /An Account has: //An account id //A balance //A date created //The static field, account Number is used to assign each //account an accountId starting with 1. public class Account private int accountId; private double balance private Date date_created private static int accountNumber = 1: 1Default counstructor. Creates object with a balance of 0 public Account ) date_created = new Date(); balance= 0; accountId = accountNumber; accountNumber++ } /Create an account with an initial balance public Account (double balance) date_created = new Date () this.balance balance; accountNumber; accountId = accountNumbert+; //Getters for each instance field below public int getAccountId () return account Id; public double getBalance ) return balance; } public Date getDateCreated ) return date_created; //Setters withdraw and deposit change the balance //Setters are not required for the dateCreated and accountId fields //since the fields cannot be changed public void withdraw (double amount) balance -= amount; } public void deposit (double amount) balance amount; } //This method returns a String representation of the Account object public String toString () { return "Account Id: Balance: balance + Date Created: date_created accountId } }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 7 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY