The main method will declare and fill a two-dimensional array named intArr with two rows and three columns with the following integer data (entered by the user via a nested for loop, so set up a scanner to use in main): 4 9 11 6 3 7 The main method will pass three things to a method named reCalc. These things are the 2D array intArr, a single character named ch (either the letter m or the letter s, which you may get from the user), and an integer value named num. Inside the method reCalc, in the event the character passed was an m, the method will multiply every value in the array passed to it by the integer value passed to it. In the event the single character was an s, the method will subtract the integer sent to it from each value. Write your program to correctly handle either letter. For this program data, that integer value should be 4, which you can choose to set up as a constant in main or obtain as user input in main. For this program, the single character sent to the method should be the letter m. Somewhere (either in main or in reCalc – your choice), you should deal with the possibility of an invalid character (something other than a lowercase m or a lowercase s.) You can do that in any one of several ways – your choice. The method named reCalc will perform the subtraction or multiplication (in this example, it would be the multiplication) and will return the manipulated array back to the main method. The main method will use a nested for loop to print the altered values of the array named intArr as two lines with three values each. In the case where the array with the above values are passed to the method named reCalc along with the integer value 4 and the lowercase letter m, the returned values in the array that are printed by main would be the following values in the following format: 16 36 44 24 12 28
The main method will declare and fill a two-dimensional array named intArr with two rows and three columns with the following integer data (entered by the user via a nested for loop, so set up a scanner to use in main):
4 9 11
6 3 7
The main method will pass three things to a method named reCalc. These things are the 2D array intArr, a single character named ch (either the letter m or the letter s, which you may get from the user), and an integer value named num.
Inside the method reCalc, in the event the character passed was an m, the method will multiply every value in the array passed to it by the integer value passed to it. In the event the single character was an s, the method will subtract the integer sent to it from each value. Write your
For this program data, that integer value should be 4, which you can choose to set up as a constant in main or obtain as user input in main. For this program, the single character sent to the method should be the letter m. Somewhere (either in main or in reCalc – your choice), you should deal with the possibility of an invalid character (something other than a lowercase m or a lowercase s.) You can do that in any one of several ways – your choice.
The method named reCalc will perform the subtraction or multiplication (in this example, it would be the multiplication) and will return the manipulated array back to the main method.
The main method will use a nested for loop to print the altered values of the array named intArr as two lines with three values each.
In the case where the array with the above values are passed to the method named reCalc along with the integer value 4 and the lowercase letter m, the returned values in the array that are printed by main would be the following values in the following format:
16 36 44
24 12 28
Step by step
Solved in 3 steps with 2 images