Question: LAB EXERCISES: (60 Minutes) 1. Add a method named countA() in the program Recursion2.cpp (provided with Lab 5 notes) which counts the number of A

 LAB EXERCISES: (60 Minutes) 1. Add a method named countA() in
the program Recursion2.cpp (provided with Lab 5 notes) which counts the number
of "A" in the given string. Sample Run 1: Output - CountAproject
(run) * DD DD Please enter any string: BANANAS Number of a'

LAB EXERCISES: (60 Minutes) 1. Add a method named countA() in the program Recursion2.cpp (provided with Lab 5 notes) which counts the number of "A" in the given string. Sample Run 1: Output - CountAproject (run) * DD DD Please enter any string: BANANAS Number of a' in the string BANANAS 1. 3 BUILD SUCCESSFUL (total time: 1 minute 58 seconds) Sample Run 2: Output - CountAproject (run) * DD Please enter any string: MANGO Number of A' in the string MANGO 1. 1 BUILD SUCCESSFUL (total time: 30 seconds) Sample Run 3: Output - Count project (run) * DD Please enter any atzing: CURRY Number of A's in the string CURRY 13 0 BUILD SUCCESSFUL (total time: 34 seconds) 2. Add a method named count7() in the program Recursion2.cpp (provided with Lab 5 notes) which returns the count of the occurrences of 7 as a digit. For example 717 yields 2. Note that mod (%) by 10 yields the rightmost digit (126 % 10 is 6), while divide (/) by 10 removes the rightmost digit (126 / 10 is 12). count7(717) - 2 count7(7) - 1 count7(123) - 0 Sample Run 1: Output - Count7Project (run) D DD Please enter any number: 717 Number of 7' in the number 717 1 2 BUILD SUCCESSFUL (total time: 4 seconds) Sample Run 2: Output - Count7Project (run) DD DD Please enter any number: 1374972397 Number of 7 in the number 1374972387 is 3 BUILD SUCCESSFUL total time: 13 seconds) Sample Run 3: Output - Count7Project (run) * DD DD Please enter any number: 123456 Number of 7's in the number 123456 0 BUILD SUCCESSFUL total time: 3 seconds) 3. Add a method named ChangeXY() in the program Recursion2.cpp (provided with Lab 5 notes) which computes recursively (no loops) a new string where all the lowercase 'x' chars have been changed to 'y' chars. changeXY("codex") "codey" changeXY("xxhixx") - "yyhiyy" changeXY("xhixhix") "yhiyniy" Sample Run 1: Output - Change Characters (run) D DD Please enter any string in lower case: codex old string was codex New ateing after changing *'s into y's 1. codey BUILD SUCCESSFUL total time: 10 seconds) Sample Run 2: Output - ChangeCharacters (run) DD D Please enter any string in lover care: xxxx Old string was whixx New string after changing *'s into y'a 11 yyhiyy BUILD SUCCESSFUL (total time: 2 seconds) Sample Run 3: Output - Change Characters (run) DD Please enter any string in lower case: yhlyhy old string was yhsyhiy New string after changing *'s into y's is yhiynay BUILD SUCCESSFUL itocal time: 2 seconds) 4. Add a method named pairStar() in the program Recursion2.cpp (provided with Lab 5 notes) which computes recursively a new string where identical chars that are adjacent in the original string are separated from each other by a "*". pairStar("hello") -- "hel*lo" pairStar("xxyy") - "x*xy*y" pairStar("aaaa") - "a*a*a*a" Sample Run 1: Output - PairStars (run) * Please enter any string: hello Old string was hello New string after inserting - in adjacent identical characters 1. helle BUILD SUCCESSFUL (total time: 13 seconds) Sample Run 2: Output - Pair Stars (run) * ID Please enter any string: myy old string was my New string after inserting in adjacent identical characters 13 ***** BUILD SUCCESSFUL (total time: 57 seconds) Sample Run 3: Output - Pair Stars (run) * D DD Please enter any string: old string was aans New string after insertings in adjacent identical characters ** ******* BUILD SUCCESSFUL (total time: 32 seconds)

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!