Question
Java Please help quick! The method takes 3 parameters: a string (file name), and two integer numbers, representing digits. Both integer parameters must be one-digit
Java Please help quick!
The method takes 3 parameters: a string (file name), and two integer numbers, representing digits. Both integer parameters must be one-digit non-zero numbers (must belong to range [1, 9]). The method opens a file with a given name, erases its current contents, and writes a series of integers into the file using the two digits provided. See sample method calls and the numeric patterns they generate below.
Hint: the pattern stops when the middle digit becomes a 1. Special case when digit parameters are equal.
Method does not return any values.
- Method throws IOExceptions instead of handling them.
- Method throws IllegalArgumentException if any of the two integer parameters is not in the right range of [1, 9]
Add Java Doc comments before the method header.
Unit tests for the method are provided.
Method header is already written into the source file.
public static void problem03(String fileName, int digit1, int digit2)
Sample method calls and patterns they generate in file named test1.txt:
problem03("test1.txt", 2, 5) => [252 343 434 525 616] problem03("test1.txt", 5, 2) => [252 343 434 525 616] problem03("test1.txt", 7, 3) => [373 464 555 646 737 828 919] problem03("test1.txt", 2, 8) => [282 373 464 555 646 737 828 919] problem03("test1.txt", 8, 8) => [888]
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