Question: Task 4 Modify the program developed in Task 3 in the following ways. 1. Add another formal parameter called op of type char to the

Task 4 Modify the program developed in Task 3 in the following ways. 1. Add another formal parameter called op of type char to the method countUp. It specifics how to calculate the next value of the counter according to the following rules: Value of op Action "+ ' currentCount = currentCount + increment currentCount = currentCount - increment (* 1 currentCount = currentCount * increment any other value print "Invalid operation" 2. Change the first call to countUp to include the actual parameter '*'. Change the second call to countUp to include the actual parameter '-'. Add a third call to countUp to include the actual parameter '?' - an invalid operation. The main method should now be as follows: public static void main (String args) System . out . printIn ("Starting Application. ..") ; Counter c = new Counter (1,3) ; c. countUp (5, ' *' ) ; Counter c1 = new Counter (5) ; c1 . countUp (2, ' -' ) ; c1 . countUp (2, '?' ) ; Compile and run the application. It should produce the output
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
