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

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