[Previous Homework] [Next Homework]

hw11 - Character Conversion using Assignment Operators


From Linux on the GL machine:
  • Create source code file called upperlower.c in your ./cmsc104/hw11 directory

  • Compile the program:
    gcc -o upperlower upperlower.c

  • Run the program to make sure it works:
    ./upperlower

  • Use the SUBMIT utility turn in the homework.
    submit cs104_grasso hw11 upperlower.c upperlower


Your program should do the following:
  • Add the following #define to help with the case conversion
    
    		#define CONVERT   'a' - 'A'
    		
  • Display a menu to the user that looks like the following:
    
    		Choose one option:
    			U - Convert to upper case
    			L - Convert to lower case
    			X - Exit program
    		
  • Use a switch statement to process the options (including invalid options).
    • Accept both upper case and lower case letters for each option in your menu.

  • Write two functions to do the case conversion: doUpper() and doLower()and call them from the appropriate case clause of the switch statement.

  • The functions should do the following:
    • Prompt the user to enter a string of text
    • Write an event controlled loop to read in one character at a time using getchar() until the character is a newline character.
      • If the character input is of the wrong case, convert it using an assignment operator and CONVERT constant.
      • Print out the character
    • After the loop, print two newline characters.


Make sure that you follow all the coding standards