You are on page 1of 4

CIS

214 C++ Programming



Monday, August 4, 2014

CIS 214 C++ Programming - Summer 2014

HOMEWORK PROJECT #10-4: 8/4/14


(3 points) The user is asked to enter any non-empty English word or sentence.

Write a funcHon named reverseAdjacents that takes the user input as std:string
reference and modies the string so that each two adjacent leLers in it are reversed.

If the string has odd number of leLers, the last leLer is unchanged.

Examples:
Input: example
Output: xemalpe

Input: hello world
Output: ehll oowlrd

Constraint/AssumpLon:
Assume that the input string is not empty, and it consists of ASCII characters

HOMEWORK PROJECT #10-5: 8/4/14


(3 points) The user is asked to enter any non-empty English word or sentence.

Write a funcHon named alterCaps that takes the user input as std:string reference
to change its capitalizaHon.

All of the leLers at even indices in that string are in lowercase
All of the leLers at odd indices in that string are in uppercase.

Examples:
Input: ExamPLE!!
Output: eXaMpLe!!

Constraints/AssumpLons:
Assume that the input string is not empty, and it consists of ASCII characters

HOMEWORK PROJECT #10-6: 8/4/14


(5 points) Implement the following mostCommonWord funcHon:

FuncLon DeclaraLon:
string mostCommonWord(string filename);!

The funcHon opens and reads that le's contents, and returns the word that occurs
most frequently in the le.

Constraints/AssumpLons:
1. Any duplicate words will occur in the le consecuHvely
2. Words are separated by one or more spaces
3. The input le contains AT LEAST one word
4. Words are non-empty, and in ASCII
5. If there is a He, use the earlier word.

Example:
The following le content will make your mostCommonWord funcHon return CIS14"
because the word CIS14 occurs 3x before the word, City, which also occurs 3x.

CIS14 CIS14 CIS14 Pasadena Pasadena
College City City City
Programming So^ware C++ C++"
4

You might also like