Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 createFileint 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
In order to generate such random numbers, dont use Math.random Instead, use the Random class with the following code:
Random rnd new Random;
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 saveFileToArrayString 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 sortBalancesint days
Sort the numbers in the int array from least to greatest You may use Arrays.sort if youd like
public static void printBalancesint days
Print all of the values in the int between square brackets with a comma between them
Eg
public static boolean hasEnoughAfterBillsint balances, int account
The cost of monthly household expenses for a family of four is approximately $
Determine if the value at the index specified by account has a positive balance after expenses have been paid
public static int numAffordSixMonthsint days
The cost of monthly household expenses for a family of four is approximately $
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
createFilenewFiletxt;
newFiletxt Contents:
outtxt Contents:
int balances saveFileToArrayouttxt;
printBalancesbalances;
sortBalancesbalances;
printBalancesbalances;
hasEnoughAfterBillsbalances;
true
numAffordSixMonthsbalances;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started