[Solved] CPSC 121 -Lab 4

$25

File Name: CPSC_121_-Lab_4.zip
File Size: 141.3 KB

SKU: [Solved] CPSC 121 -Lab 4 Category: Tag:
5/5 - (1 vote)

Functions Create a program that:

  1. Declare a string and assign it an arbitrary starting value of your choosing
  2. Display the current contents of your string, then displays the following menu. If a function returns a string, it should replace the contents of your string, otherwise display the resulting information and leave the string unchanged. Function headers are provided; they should be used as-is in the manner appropriate.
    1. string getInput()
      1. MUST use getline (with cin)
        1. Due to differences in treatment of the
          character when we hit enter, cin.ignore may have to be used to fix the input buffer
      2. Reads user input from cin and stores it in the string being used. Contents will set initial state for the string next loop through program.
    2. string printBetween(int a, int b, int step = 1)
      1. Will return a string containing all numbers between a and b, including a and b, counting up
      2. G. a = 6, b = 3, output = 3456 (dont use spaces)
        1. If only two values are provided in the function call, assumes step of 1
  • Order is unassumed, but data is displayed counting up
  1. string nonalnum_removed(string input)
    1. Returns the string provided as input with all characters that are neither digits nor alphabetic removed
      1. Will probably involve function isalnum (slides/internet for references)
      2. If a string, str, has its length changed, any saved results from str.length() calls will be STALE, meaning they no longer reflect our data
    2. string alphabet_numberified(string input)
      1. Returns the string provided as input, except with (only) alphabetic characters converted to their character codes within the string
        1. 11a11 would become 119711
      2. int sumDigits(string digitString)
        1. Attempts to read each character as a digit, and returns the sum
        2. Inclusion of non-digit characters should result in a notification (via cout) of the character that could not be summed up
      3. void saveString(string savedStr)
        1. Prints the current strings contents to a file named <your lab filename>.txt
          1. You can overwrite the previous contents
        2. Asks the user if they would like to return to step 2, or exit.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CPSC 121 -Lab 4
$25