Professional Documents
Culture Documents
Ap String Programs-2014
Ap String Programs-2014
Be sure to include any pre and post conditions if you use any methods. Be sure
to comment ALL methods and segments thoroughly and meet the programming
expectations.
1.
Create a program that will take an input string and count all of the vowels
in the string. For the input word, the word should be printed and the
number of vowels in the word should be printed. Save the program as
VowelCounter your vowelcounter will use the countMe class.
Create a Class countMe that:
constructor takes in the string
isVowel that has an integer parameter of the
location to be checked and returns whether the
letter was a vowel
2.
3.
Im in a
palindrome
Write a program that converts a sentence into PIG LATIN. You may choose
to change your sentence to uppercase or lowercase to make your output
look consistent (the choice is up to you).
the word off (hint keep track of what letter you are at
(must be global)), change to piglatin and add it to your
new phrase)
ChangePig changes the word to piglatin (hint you will
want to loop to cut off the first letter until you hit a
vowel)
4.
Create a class called Cutter that has the following methods: (note
Cutter will not have a constructorwe will just use Cutter for its
methods)
SliceNAdd that takes in a stringcuts apart the string,
changes it to a number, and adds the digits up. The method
should return the new number.
IsGreater takes in a number and returns whether the
number is > 9
NineCast takes in a number and returns whether the
number = 9