12 Aug Suppose you are a regional manager of BP credit card company, and you want to develop a simple
Suppose you are a regional manager of BP credit card company, and you want to develop a simple
JAVA program that managing the remaining balance for each customer.
Write a simple JAVA program following the direction below:
Create a class Balance that
1) has the following (private) instance variables:
– An integer variable for the customer ID;
A double variable for the remaining balance ($).
2) has the following (public) instance methods:
-Constructor method with two arguments: one for the customer ID, one for the remaining balance
($)
- Set the customer ID and the remaining balance ($) to the parameter values;
A method to set the membership ID;
A method to set the remaining balance (5);
A method to retrieve the customer ID-
A method to retrieve the remaining balance ($);
A method to print customer information:
– Print the customer ID and the remaining balance in one line, in a properly aligned format ( use printh).
Create a class Final that has main method.
In the main method, do the followings:
Define array of 100 Balance objects:
Use a loop to read in data from the file. In each iteration, use nextint) to read in the customer ID
and nextDouble0) to read in the remaining balance:
- The. Txt file is structured as follows. For simplicity, assume we only have five data points
- 1001 500
- 1002 1500
- 1003 2800
- 1004 3100
- 1005 800
- The first number for each row is the customer ID and the second number for each row is the remaining balance.
- Instantiate array element by using the constructor method to create a Balance object with customer ID and remaining balance retrieved from the given .txt file for each iteration of while loop;
- Use a loop to print out all five Balance objects’ information. In each loop iteration, let one array element call the print method.
- Use a loop to sum of the remaining balance of all five Balance objects.
- Hint: Use the method declared in Balance class
- Write the sum of the remaining balance of all five Balance objects (display two decimal places only) into a new file named “output.txt”.
- Main method may throw exception. However, we do not want to explicitly handle it. In the method header. throw checked exception (do not use try-catch statements).
