Java training #2

The Purpose of this training is to get familiar with:

  • Strings and some of their methods and behaviors
  • Basic work with Arrays
  1. Get a sentence as an input from the user and print to the screen each word of the sentence in a different line

  2. Get a sentence as an input and print the reversed sentence.
    Example:
    Input: hello world
    Output: world hello

  3. Get a sentence as an input and print to the screen:
        The number of words in the sentence
        The number of times that the letter ‘a’ appears,
        The number of times that the letter ‘f’ exists
        The number of commas in the sentence

  4. Get a sentence as an input and a number as an input. and do the following
    Example 1:
    Input: Hello world 3
    Output:
     hel
     lo
    wor
    ld

    Example 2:
    Input: taltaltal 3
    Output:
    tal
    tal
    tal

Note: In the examples above, the number 3 means => 3 letters will be print each time. space can be considered as letter  character.