In Java Given the below BankAccount.java file, provide an accompanying BankAccountDriver.java file that “exercises” (tests) the BankAccount class by calling its methods. Specifically, your BankAccountDriver class should: • Declare and instantiate a BankAccount object. • Prompt the user for a customer name. • Call setCustomer, passing in the user-entered customer name. • Prompt the user for a bank account number. • Call setAccountNum, passing in the user-entered bank account number. • Call printAccountInfo. Do not forget to use proper style in your BankAccountDriver.java file (including comments and a prologue section at the top of the file). Write your code so that it works in conjunction with the below class. When run, your program should produce the output shown in the subsequent sample session. /***************************************************** * BankAccount.java * This program stores and prints information * for a bank account. *****************************************************/ public class BankAccount { private String customer; // customer's name private int accountNum; // bank account number //************************************************** public void setCustomer(String customer) { this.customer = customer; } // end setCustomer public void setAccountNum(int accountNum) { this.accountNum = accountNum; } // end setAccountNum //************************************************** // This method prints a bank account's information. public void printAccountInfo() { System.out.println( this.customer + "'s account number is " + this.accountNum + "."); } // end printAccountInfo } // end class BankAccount Sample session: Customer name: William Gates Account number: 123456 William Gates's account number is 123456.
In Java
Given the below BankAccount.java file, provide an accompanying
BankAccountDriver.java file that “exercises” (tests) the BankAccount class by
calling its methods. Specifically, your BankAccountDriver class should:
• Declare and instantiate a BankAccount object.
• Prompt the user for a customer name.
• Call setCustomer, passing in the user-entered customer name.
• Prompt the user for a bank account number.
• Call setAccountNum, passing in the user-entered bank account number.
• Call printAccountInfo.
Do not forget to use proper style in your BankAccountDriver.java file (including
comments and a prologue section at the top of the file).
Write your code so that it works in conjunction with the below class. When run, your
program should produce the output shown in the subsequent sample session.
/*****************************************************
* BankAccount.java
* This program stores and prints information
* for a bank account.
*****************************************************/
public class BankAccount
{
private String customer; // customer's name
private int accountNum; // bank account number
//**************************************************
public void setCustomer(String customer)
{
this.customer = customer;
} // end setCustomer
public void setAccountNum(int accountNum)
{
this.accountNum = accountNum;
} // end setAccountNum
//**************************************************
// This method prints a bank account's information.
public void printAccountInfo()
{
System.out.println(
this.customer + "'s account number is " +
this.accountNum + ".");
} // end printAccountInfo
} // end class BankAccount
Sample session:
Customer name: William Gates
Account number: 123456
William Gates's account number is 123456.
![](/static/compass_v2/shared-icons/check-mark.png)
- Import the java.util.Scanner library.
- Create a class BankAccountDriver with a main method.
- Inside the main method, create a Scanner object input to read input from the user.
- Create a BankAccount object account.
- Prompt the user for a customer name and store it in a String variable customer.
- Call the setCustomer method on account and pass in customer.
- Prompt the user for a bank account number and store it in an int variable accountNum.
- Call the setAccountNum method on account and pass in accountNum.
- Call the printAccountInfo method on account to display the customer name and account number.
- End the main method.
- End the BankAccountDriver class.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)