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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question

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

Expert Solution
steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,