Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Complete a Java program named ARMgr that maintains customer accounts receivable in a database. The code to initialize the CustomerAccountsDB database table and add a

Complete a Java program named ARMgr that maintains customer accounts receivable in a database.

The code to initialize the CustomerAccountsDB database table and add a set of customer accounts is provided.

Finish the code in these 3 methods in CustomerAccountDB.java to update or query the database:

purchase(double amountOfPurchase)

payment(double amountOfPayment)

getCustomerName()

Hint: For getCustomerName(), look at the getAccountBalance() method to see an example of querying data from the database. For the purchase() and payment() methods, look at the addCustomerAccount() method to see an example of updating information in the database.

Setting Up the Project: Download the derby.jar file and save it where Eclipse can use it, such as on your Desktop.

Download the Homework5Files.zip file containing these files: https://drive.google.com/drive/folders/0B41Z5suN4j28Z3gyMTlMNVB5ZmM?usp=sharing

database.properties

Properties file for the database connection

CustomerAccountDB.java

Class to update and query CustomerAccountdb rows

CustomerAccountsDB.java

Class to initialize the CustomerAccountDB table and operate on all customer accounts

ARMgr.java

Main method with user interface

SimpleDataSource.java

SimpleDataSource class to simplify database connections

To run the ARMgr Java program in Eclipse, create a new project, copy all of the Java files into the src folder of your project, and copy the database.properties file into the projects folder. Open the Project Properties dialog and select Java Build Paths, then click the Libraries tab. Click the Add JARs button, use the Open dialog to find the file derby.jar, and click the Open button. Click OK to save these changes to the Projects properties. When you first run the program, the database is empty! Use the (I)nitialize option to setup the accounts receivable database with the initial set of customer accounts.

Here is a sample run of the program:

I) Initialize database A)ddCustomerAccount P)urchase paY)ment C)heckCustomerAccount L)istCustomers Q)uit

I

Enter 'YES' if you wish to reinitialize the customer account list:

YES

Notice: inserted customer account 1001 Apple County Grocery 24.95

Notice: inserted customer account 1002 Uptown Grill 29.95

Notice: inserted customer account 1003 Skyway Shop 19.99

Notice: inserted customer account 1004 River City Music 2.95

I) Initialize database A)ddCustomerAccount P)urchase paY)ment C)heckCustomerAccount L)istCustomers Q)uit

A

Enter new customer account numer: 1005

Enter new customer name: Eastside Deli

Enter new customer account balance: 205.95

I) Initialize database A)ddCustomerAccount P)urchase paY)ment C)heckCustomerAccount L)istCustomers Q)uit

L

Customer Customer Account: 1001 Apple County Grocery 24.95

Customer Customer Account: 1002 Uptown Grill 29.95

Customer Customer Account: 1003 Skyway Shop 19.99

Customer Customer Account: 1004 River City Music 2.95

Customer Customer Account: 1005 Eastside Deli 205.95

I) Initialize database A)ddCustomerAccount P)urchase paY)ment C)heckCustomerAccount L)istCustomers Q)uit

P

Enter customer account number for purchase: 1004

Customer 1004: Customer Account: 1004 River City Music 2.95

Enter amount of purchase: 210.55

Customer Account 1004 now has balance 213.50.

I) Initialize database A)ddCustomerAccount P)urchase paY)ment C)heckCustomerAccount L)istCustomers Q)uit

Y

Enter customer account number for payment: 1003

Customer 1003: Customer Account: 1003 Skyway Shop 19.99

Enter amount of payment: 19.99

Customer 1003 now has balance 0.00.

I) Initialize database A)ddCustomerAccount P)urchase paY)ment C)heckCustomerAccount L)istCustomers Q)uit

C

Enter customer account number to check: 1001

Customer: 1001 Customer Account: 1001 Apple County Grocery 24.95

I) Initialize database A)ddCustomerAccount P)urchase paY)ment C)heckCustomerAccount L)istCustomers Q)uit

q

When you run the program, if you get the error:

Exception in thread "main" java.io.FileNotFoundException: database.properties

Then make sure you have the database.properties file copied into your project folder, and make sure you have the database.properties filename specified correctly in the Run/Debug Settings.

If you receive the error:

Exception in thread "main" java.sql.SQLException: No suitable driver

Make sure that derby.jar has been added to the Libraries list on the Project Properties Java Build Paths page.

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_2

Step: 3

blur-text-image_3

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

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions

Question

What is a temporary difference? Give two examples.

Answered: 1 week ago