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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started