Java

TOPIC 50 – WALKING THROUGH A STRING

 

LESSON WORK

 

 

QUESTION #1

Write a program that gets a word from the user and counts the number of vowels in that word.  Results should be outputted to screen.

 

QUESTION #2

Write a program that gets a word from the user.  It then switches the case of every single letter and outputs this new String to screen. 

 

QUESTION #3

Write a program that gets a word from the user.  It then removes all occurrences of the letter ‘a’ (both upper and lower case “a”).  The new String should be outputted to screen.

 

QUESTION #4

Write a program that gets a word from the user.  It is to output a new String that is in inverse order, that contains no letters d (both upper case and lower case) and has all letters swapped cases.

 

If word = “dumb”, the result should be “BMU”

If word = “DodO”, the result should be “oO

If word = “daMaged”, the result should be “EGAmA