Question: Write code to enter information about a product, and show the value of the customers account as the accounts balance is increased a number of

Write code to enter information about a product, and show the value of the customers account as the accounts balance is increased a number of times by customer purchases. The CustomerAccount.java class is provided as a starting point; complete it by writing the AddCustomerPurchases.java class code as a possible starting point is shown below. In the AddCustomerPurchases classs main method:

Ask the user to enter the customer name, account number, and initial balance.

Create a CustomerAccount object using the customer name, account number, and initial balance.

Write a loop that asks the user for the amount purchased by the customer, and then uses the CustomerAccount objects purchase() method to add the purchase amount to the customers account. Continue the loop until the user enters 0. Each time through the loop, after applying the purchase, use the CustomerAccounts toString() method to get the String of information about the customers account, and print the String.

Sample program run (user input is bold):

Enter customer name: Applied Ag Enter customer account number: 5150 Enter customer account initial balance: 525.50 Enter amount of customer purchase (0 to quit): 55.00 5150 Applied Ag 580.50 Enter amount of customer purchase (0 to quit): 20.00 5150 Applied Ag 600.50 Enter amount of customer purchase (0 to quit): 0

Be sure to name the classes AddCustomerPurchases and CustomerAccount. If you do not use the exact names (with the capital letters as specified), the automatic testing program will not be able to run your program and points will be lost. Fill in your name in the @author section of the comment in the AddCustomerPurchases. If you do not, points will be deducted. Be sure to read the data in the order specified so the automatic testing program can provide the input correctly to your program.

/**

* Main class for the AddCustomerPurchases program.

* @author

*/

public class AddCustomerPurchases

{

public static void main(String[] args)

{

Scanner in = new Scanner(System.in);

// Ask the user to enter the customer name,

// account number, and initial account balance.

// Create a CustomerAccount object using the

// name, account number, and initial balance

// entered above.

// Loop: Ask the user for the amount purchased

// and record the purchase to the customer's

// account using the purchase() method on the

// customer account object created above.

// Print the updated customer account information

// after each recorded purchase.

// Finish the loop when the user enters 0.

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!