BlueBook
p129ex5 - Find the Character
Write a program that takes as input a single character and then a sentence, terminated by a period. The program should echo-print the input (that is, print it in the form in which it was read) and give a count of the number of times that the character appears in the sentence. Your program should not be case-sensitive - that is, uppercase letters should be considered equivalent to the corresponding lowercase letters.
Input
The first line of the input consists of one character. The second line of the input consists of a sentence terminated by a period.
Output
Output the number of times the character appears in the sentence.
Sample Input 1
o
Why so serious son.
Sample Output 1
Why so serious son.
3
Sample Input 2
y
You want the truth? You can't handle the truth.
Sample Output 2
You want the truth? You can't handle the truth.
2
All Submissions
Best Solutions
Point Value: 3
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 22, 2008
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
Can someone tell me my problem?
Yes, you should print the string and number of times (this should be in the output format, I guess)
For example: Why so serious son. --it thinks that only "Why" is part of the sentence.
How do I fix this?
2. Use the nextLine() method
(I am using Pascal).