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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education