Not a member?     Existing members login below:
$$$ Get Money for Sharing FREE eBooks! Click here for details $$$

Fundamentals of Computer Programming with C#

Chapter 25. Sample
Programming Exam –
Topic #2
In This Chapter
In this chapter, we will take a look at the specifications of a few practical
algorithmic problems from a sample programming exam, and we will offer
solutions. While solving the problems, we will follow the guidelines from the
chapter Problem Solving Methodology, and we are going to illustrate their
Problem 1: Counting the Uppercase / Lowercase
Words in a Text
Write a program that counts the words in a text entered from the console.
The program must output the total number of words, the number of words
written in uppercase and the number of words written in lowercase. If a
word appears more than once in the text, each repetition counts as a new
occurrence. Every character that is not a letter counts as a word separator.
Sample input:
Welcome to your first programming exam! Can you think of a
solution to this problem and write it down? GOOD LUCK!
Sample output:
Word count: 21
Upper case words: 2
Lower case words: 17
Coming Up with an Appropriate Idea for a Solution
Intuitively, it comes to mind, that the problem may be solved by splitting
the text up into separate words and counting those that meet the
specified conditions.
Obviously, this approach is correct, but far too general, and it doesn’t lead to
a particular method for solving the problem. Let’s try to be more specific,
and see if by doing so, we could implement an algorithm that will lead to a