piowit

java.lab2task

Oct 9th, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. Programming 3
  2.  
  3. Lab 2
  4.  
  5. 09.10.2012: First steps in Java.
  6. Theme: Arrays.
  7.  
  8. On today's labs you will be writing a program, which will be working with a long sentence (example: a poem). Functionalities, you will be asked to implement include: dividing a sentence into words, sorting words in alphabetical order, counting occurences of words in the sentence, generating a sentence (a not necessary meaningful set of words).
  9.  
  10. Declare following variable:
  11.  
  12. String sentence = "How are you, are you ok? If not please say something. I would like to ask you how was your day. What are your plans for the rest of the week? Any good plans for the weekend? Just-in-case if we don't see each other: have a joyful day!";
  13.  
  14. It is your sentence, with which you will be working today.
  15. Assume that a word is a substring of a sentence, that may be limited by:
  16. - blank space (" ") - please note, that there might be more than one white space,
  17. - a punctuation mark (for example: ".", ",","!" and so on).
  18. Assume that a word is a substring containing letters only. Hyphenated word is one word, numbers are always ommited.
  19.  
  20. Subtask 1: Divide variable "sentence" into separate words. Print each word out in separate line on the console, in the order, in which they are in the sentence. (4 pts)
  21.  
  22. Subtask 2: Count words occurrences. On the console print each word and a number of how many times it was repeated in the sentence. (4 pts)
  23.  
  24. Subtask 3: Sort words in alphabethical ascending order. Words, that occur more than once, should be printed only once. Print sorted words on the console. (5 pts)
  25.  
  26. All tasks require manipulations with Strings and arrays of characters. Here is the list of inbuilt helpers:
  27. http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html
  28. http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Character.html
  29.  
  30. How your work will be graded?
  31. Subtask 1: Dividing sentence into words: 4 pts.
  32. Subtask 2: Counting occurrences of words in the sentence: 4 pts.
  33. Subtask 3: Sorting: 5 pts.
  34. Compilation errors, style: 2 pt.
  35.  
  36. Together: 15 pts.
  37. 100% = 10 pts, so you don't need to implement all of functionalities to get full score!
Advertisement
Add Comment
Please, Sign In to add comment