Question: JAVA Let's use this String array[] parameter in our program to pass information into our main() method and use it to do some computations. pseudocode

JAVA

Let's use this String array[] parameter in our program to pass information into our main() method and use it to do some computations.

pseudocode

pass in an operation and then perform that operation on all successive numbers passed into our main() method application.

Example 1 command line execution of our program:

>java MyCommandLine + 1 2 3 4 5

output would be:

1 + 2 + 3 + 4 + 5 = 15

example 2:

>java MyCommandLine - 15 2 3

output would be:

15 - 2 - 3 = 10

example 3:

>java MyCommandLine * 3 2 5

output would be:

3 * 2 * 5 = 30

Sections and concepts that will help with this lab: variable-length argument list 7.9, pass arguments to the main() method 7.13, Type Casting and Numeric Conversions 2.16, foreach loops 7.2.7

Modularize your logic: create 1 or more method(s) to process our String array[].

use a Switch statement on the operation (first element in the array[]) + * -

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!