Question
11.7 Week 9 Lab: Functions Answer only in Basic C. (1) Prompt the user to enter a string of their choosing (up to 100 characters
11.7 Week 9 Lab: Functions Answer only in Basic C.
(1) Prompt the user to enter a string of their choosing (up to 100 characters long, which could include whitespaces). Then, output the string to the screen. (1 pt)
(2) Complete the getNumAlpha() function, which returns the number of letters in the user's string. (1 pt)
(3) In main(), call the getNumAlpha() function and then output the returned result. (1 pt)
(4) Complete the encodeChar() function, which returns the character stored in replaceChar if thisChar matches thatChar. Otherwise, the function returns the character stored in thisChar. (1 pt)
(5) Complete the encodeString() function, which should loop through the characters in usrStr making the following changes if necessary:
- replace any numeric digit ('0'-'9') with '#'
- replace the upper case letter 'O' with the number '0'
- replace the upper case letter 'I' with the number '1'
- replace the upper case letter 'Z' with the number '2'
- replace the upper case letter 'E' with the number '3'
- replace the upper case letter 'H' with the number '4'
- replace the lower case letter 's' with the number '5'
- replace the lower case letter 'b' with the number '6'
- replace the upper case letter 'L' with the number '7'
- replace the upper case letter 'B' with the number '8'
- replace the lower case letter 'g' with the number '9'
All but the first replacement should be done by calling the encodeChar() function for each. (1 pt)
(6) In main(), call the encodeString() function and output the encoded string. (1 pt)
Sample Input/Output:
Enter a message: THE Answer to Life is 42... and big BIG ZOOs! You entered: THE Answer to Life is 42... and big BIG ZOOs! Number of characters: 46 Number of letters: 30 Encoded message: T43 An5wer to 7ife i5 ##... and 6i9 81G 2005!
Use the template provided. Do not change the function definitions. Simply fill in your code without changing the template.
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