Question: With your new BankingInfo.java class, you can open it by double clicking on it in the Package Explorer panel ( if it did not open

With your new BankingInfo.java class, you can open it by double clicking on it in the Package Explorer panel (if it did not open automatically) and begin coding. Insert the following methods into this class:
public static void createFile(int numOfNumbers, String fileName)
Using numOfNumbers, create a file named fileName using the PrintWriter consisting of that many random numbers, limiting the max value of the numbers to 10000
In order to generate such random numbers, dont use Math.random(). Instead, use the Random class with the following code:
Random rnd = new Random(100);
Whenever you want to get a new random number, use the rnd object with the nextInt() method. Put the upper bound (max value) you want inside the parenthesis for the method call
You should only add a random number to the file if it is positive, but you should still have numOfNumber numbers in your file when complete
Print a generic error message of your choice if an Exception occurs
public static int[] saveFileToArray(String fileName)
From a file called fileName, save all of the int values in that file to an array, then return that array
Hint: youll either need to insert a new value into your array each time you read a number from the file, or youll need to know the number of values in the file beforehand by parsing through it once before
Dont use an ArrayList
Print a generic error message of your choice if an Exception occurs
public static void sortBalances(int[] days)
Sort the numbers in the int array from least to greatest You may use Arrays.sort() if youd like
public static void printBalances(int[] days)
Print all of the values in the int[] between square brackets with a comma between them
E.g.,[1,4,6,7]
public static boolean hasEnoughAfterBills(int[] balances, int account)
The cost of monthly household expenses for a family of four is approximately $7,875
Determine if the value at the index specified by account has a positive balance after expenses have been paid
public static int numAffordSixMonths(int[] days)
The cost of monthly household expenses for a family of four is approximately $7,875
Over all bank account balances in int[], determine how many could afford to pay expenses for at least six months and still have money
Once you are finished, execute and test your program by clicking Run -> Run at the top of the Eclipse IDE, or the green play button just below Refactor and Navigate. Test your program by comparing to the sample runs given below. NOTE: Your output should match the example output exactly!
You must include method comments as JavaDoc and individual comments to explain complex blocks of code. Furthermore, include a class header JavaDoc comment that contains your name, section, assignment, and assignment description. These are graded (see the rubric below), so dont forget to do these! If you dont know how to do these, ask your instructor
Test Runs
createFile(5,newFile.txt);
newFile.txt Contents: 4391536250278743598834291
out.txt Contents: 439153625027874359883429124666290361728847713
int[] balances = saveFileToArray(out.txt);
printBalances(balances);
[43915,36250,27874,35988,34291,24666,29036,17288,49723,47713]
sortBalances(balances);
printBalances(balances);
[17288,24666,27874,29036,34291,35988,36250,43915,47713,49723]
hasEnoughAfterBills(balances,6);
true
numAffordSixMonths(balances);
2

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 Programming Questions!