We continued to do our lab 8.
The second question is asked us to write a program that has the following methods to:
a. count the number of letters in a string using the following header:
public static int countLetters(String s)
b. find the number of occurences of a specified character in a string using the following header:
public static int countCharacter(String str, char a)
The answers are as following :
(a) The user is prompt to enter a string, then the string is counted using for while loops. After int i is greater than length of string, the number of letters will be returned to countLetter(string).
(b) a is declared as a variable for specific character and it is counted using loops. For example, the number of occurences of a the specific character 't' in "Kitty" is 2.
That's all for today's lab. The following question I will investigate in home and post it soon.
Thank you very muchhh!^^
LIM XUE TING
(b) a is declared as a variable for specific character and it is counted using loops. For example, the number of occurences of a the specific character 't' in "Kitty" is 2.
Thank you very muchhh!^^
LIM XUE TING
183615
SSK3100
(Group15)
Next blog: hennyabigail.blogspot.com (Henny
Abigailwillyen Sinjus)