1 / 3

Working with Strings

Working with Strings. Characters in a String can be identified by their index #. The first character in a String has index # 0. You need to know the following String methods:. Examples…. String coin = “Nickel”; Demo…. Assignments. ( Rush ) Prompt the user to enter a word.

nyla
Télécharger la présentation

Working with Strings

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Working with Strings • Characters in a String can be identified by their index #. • The first character in a String has index # 0. • You need to know the following String methods:

  2. Examples… String coin = “Nickel”; Demo…

  3. Assignments • (Rush) Prompt the user to enter a word. • If the word is “Neil,” then ask the user to enter a letter. If the letter is a or b, display “Peart.” If it’s another letter, display “Xanadu.” • If the word is “Geddy,” then ask the user to enter a number. If the number is odd and divisible by 9, display “Lee.” If the number is negative or equals 2012, display “YYZ.” 2. (Middle) Prompt the user to enter their middle name. • If the 1st letter is a vowel, display “Vowel”, otherwise, “consonant” • If there are more than 8 letters in the name, display “long”, if between 5 and 8 (inclusive), display “medium”, otherwise, display “short.” • Display whether the # of letters in the name is even or odd. Also, if it’s even, display whether or not it is divisible by 4. If it’s odd, display whether or not it is divisible by 5. • If the letter ‘a’ is in the name, display the first index # it was found at (example: “The letter a was found at index #3”) If it is not found, then say “The letter a was not found.” • If the first and last letters in the name are the same, display “same,” otherwise “different” • If the 2nd letter and the 2nd-to-last letter are both k, display “YES”

More Related