1 / 13

CSE 1020:Software Development

CSE 1020:Software Development. Mark Shtern. Summary. Error handling String Handling The masquerade and the + operation Applications Character Frequency Character Substitution Fixed-Size codes Variable-Size code StringBuffer. Exercise 6.15.

more
Download Presentation

CSE 1020:Software Development

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. CSE 1020:Software Development Mark Shtern

  2. Summary • Error handling • String Handling • The masquerade and the + operation • Applications • Character Frequency • Character Substitution • Fixed-Size codes • Variable-Size code • StringBuffer

  3. Exercise 6.15 Write a program that reads a string and outputs its length exclusive of any trailing asterisks For example, if the user entered “java**” the output should be 4 If the user entered “**” the output should be 0

  4. Exercise 6.18 Write a program that reads a string and corrects one aspect of its spelling as follows: The letter pair “ei” is replaced by “ie” unless it is preceded by c For example, “BELEIVE, seive, conceive” becomes “BELIEVE, sieve, conceive”

  5. Regular Expression

  6. Pattern Matching • Pattern matching problems: • Determine whether a given string is made up of two words • Determine whether a given string contains an integer surrounded by letters and separated from them by whitespace

  7. Regular expression • It is a string that describes a pattern in a formal fashion • Pattern example: • "((0[0-9])||(1[0-2])):[0-5][0-9] [ap]m “  time

  8. Character Specification • Range • [a-m] • Union • [a-m[A-M]] • Set • [abc] • Negation • [^abc] • Intersection • [a-m&&[^ck]]

  9. Predefined specification • Any character • . • A digit • \d • A whitespace character • \s • A word character • \w • A punctuation character • \p

  10. Quantifiers • x, once or not at all x? • x, zero or more times • x* • x, one or more times • x+ • x, at least n but not than m times • x{n,m}

  11. String class • Methods • matches • replaceAll • split

  12. Command-Line Arguments • Application launches as following • java <class name> <arg1> <arg2> <arg3> • Access to command line arguments • arg[0]  arg1 • arg[1]  arg2 • arg[2]  arg3

  13. Exercise 6.22 • Write a program that reads a DNA sequence from the user and determines whether it is valid • To be valid it must: • Contain only the letters A C G T • Start with ATG • Have a character count that is a multiple of 3

More Related