This program is going to maintain a list of customers’ names and bank account balances. 1. Create a class called CustomerList with a main method that instantiates an ArrayList of String objects called customerName. Invoke the add method to add the following names into the ArrayList: Cathy Ben Jorge Wanda Freddie 1. Print each name in the ArrayList using a for a loop. 2. Create another ArrayList object called customerBalance, to save users’ balance. What is the type of this ArrayList? double or Double? You just need to declare this ArrayList and leave it empty for now. 3. For each customer, print the name and ask the user to enter the initial balance for this customer. Save the initial balance into ArrayList customerBalance. Use a loop to get this done for all 5 customers.   The program should print out this for the first customer: Example: Please enter the account balance for Cathy: (waiting for user’s input …)   Code: for(int i=0; i<5;i++) { Print(“Please enter the account balance for ”+customerName.get(i)); customerBalance.add(scan.nextDouble()); }   4. Print the balance for each customer to validate that you did right in the step above.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

This program is going to maintain a list of customers’ names and bank account balances.

1. Create a class called CustomerList with a main method that instantiates an ArrayList of String objects called customerName. Invoke the add method to add the following names into the ArrayList:

Cathy

Ben

Jorge

Wanda

Freddie

1. Print each name in the ArrayList using a for a loop.

2. Create another ArrayList object called customerBalance, to save users’ balance. What is the type of this ArrayList? double or Double? You just need to declare this ArrayList and leave it empty for now.

3. For each customer, print the name and ask the user to enter the initial balance for this customer. Save the initial balance into ArrayList customerBalance. Use a loop to get this done for all 5 customers.

 

The program should print out this for the first customer:

Example:

Please enter the account balance for Cathy:

(waiting for user’s input …)

 

Code:

for(int i=0; i<5;i++)

{

Print(“Please enter the account balance for ”+customerName.get(i));

customerBalance.add(scan.nextDouble());

}

 

4. Print the balance for each customer to validate that you did right in the step above.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,