Write program Sum.java that just prints the strings that it is given at the command line, one
Fantastic news! We've Found the answer you've been seeking!
Question:
- Write program Sum.java that just prints the strings that it is given at the command line, one per line. If nothing is given at the command line, print "No arguments".
- Modify your program (Make a copy and rename it as Sum1.java) so that it assumes the arguments given at the command line are integers. If there are no arguments, print a message. If there is at least one argument, compute and print the sum of the arguments. Note that you will need to use the parseInt method of the Integer class to extract integer values from the strings that are passed in. If any non-integer values are passed in, your program will produce an error, which is unavoidable at this point.
- Test your program thoroughly using different numbers of command line arguments.
Note: command line arguments are those which are passed to the main method. You have to pass all arguments through command line. You cannot use scanner to get input.
Related Book For
International Marketing And Export Management
ISBN: 9781292016924
8th Edition
Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr
Posted Date: