The purpose of this project is to reinforce the knowledge from Chapter Six of the textbook. The students are required to write the following two overloaded methods:

The purpose of this project is to reinforce the knowledge from Chapter Six of the textbook. The students are required to write the following two overloaded methods:

1. public static int countLetters(String s) which count the number of English letters in given String s.
2. public static int countLetters(String s, char c) which count the number of English letter c (not case sensitive) in given String s. If c is not an English letter, returns - ‐1.

Write a JAVA test program with main function.When the program run, it shall run like: (The bold and italic ones are input)

Enter a string: hello 123$% world
Enter a char: 3

The result of calling function int countLetters(String s) is: 10
The result of calling function int countLetters(String s, char c) is: ‐1
Do you want to do another test? Y/N: y
Enter a string: %$#1234567 89 Hello hays
Enter a char: h

The result of calling function int countLetters(String s) is: 9
The result of calling function int countLetters(String s,char c) is: 2

Comment below for this Answer.

Post a Comment

0 Comments