logo CodeStepByStep logo

Surveys

Write a method named Surveys that finds the sum of unique answers given to a collection of Surveys as described below. Your method accepts a string representing a file name as a parameter where the file data consists of groups of lines separated by a blank line. Each non-empty line contains some subset of the lowercase letters a-z. Your goal is to find the total number of distinct letters used by each blank-line-separated group, sum them, and return this sum. For example, if the file named Surveys.txt contains the following:

ab
ac

xyz
y
k

The first clump contains 3 unique letters: a, b, and c. The second clump contains 4 unique letters: x, y, z, and k. So the call of Surveys("Surveys.txt") should return 3 + 4 = 7.

You may assume that the file exists and is readable, that it follows the format described above, and that there will be at least one clump of Surveys in the file.

Method: Write a C# method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.