NAME______DATE ______

  1. Write a program called StringYourSub that inputs a string from the user, then prints out the length of that string, and prompts the user to enter two integers from 1 to the length of the string. Your program will then print out the part of the string between those numbers. Assume that your little brother is using your program and he counts from 1 instead of 0 and expects the last character to show up - you are basically making a slightly more intuitive version of .substring() for him.

Example

Enter your string:

<user types in: “I love computers” without the quotes>

Your string has length 16. Enter the numbers you want to look between.

user enters 3>

user enters 6>

The part of the string between 3 and 6 is: love

// notice that we computer scientists might count character 3 as an o, but this is your little brother, so he thinks it is an l. Make him happy.

  1. Write a program called StringTypo that takes in a string from the user (you should assume it has at least 3 characters), and removes a RANDOM character from the string and prints out whatever is left of the user’s original string. The program should be able to remove any character.

Example

user types in: “I am the greatest” >

Your program could print “Iam the greatest” (removing the space) OR perhaps “I am the geatest” or even “ am the greatest.”

  1. Write a program called StringLetterSwitcherthat will input a sentence, and then two letters, and then switch all instances of those letters. It will then print out the switched sentence.

Example

user types in: “I like to eat bananas” >

user types in: “e” >

user types in: “a” >

Your program would print “I lika to aetbenenes". Assume that the user will enter a string without any numbers.

EXTRA CREDIT (You may do 1) – 5 points on a previous quiz, test, lab, or project.

  1. Write a program called StringCaps that inputs a sentence from the user. It should put the first five characters in all capital letters and then put the rest in lower case and print that. For instance, if the user types in “Batman: The Dark”, it would print out “BATMAn: the dark”.

Example

<user types in: “Batman: The Dark” >

It would print out “BATMAn: the dark”.

  1. Write a program called StringStart that will have the user input a string, and then a second string (that is contained in the first). Using the string functions from class, it will then print out the part of the string from the second string on.

Example

<user types in: “Batman: The Dark Knight Rises” >

user types in: “an” >

Your program should output the string starting from “an”, so it should print out:

an: the Dark Knight Rises

You may assume that the user will enter something for the second string that IS contained in the first.