Frequency output of letters from input

Hey everyone,
This is my first time posting here. Sorry if it is a repost.
I just started learning C++ about 2 months ago and I need some help with an assignment.
"Write a program frequencies.cpp that reads from input and outputs the frequencies of the letters in the text(not case sensitive)."
This much I have already done.
Now as a challenge we are supposed to modify our code so that it is able to distinguish between 4 languages (for example: english, french, german and italian) using letter frequencies of each language (http://en.wikipedia.org/wiki/Letter_frequency).
I'm not sure how to proceed can anyone point me in the right direction?
Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <ios>


using namespace std;

int main () {
	int freq[27]; //each index counts a letter
	
	for (int i =0; i<27; ++i) {
		freq[i]=0;				//initialize each letter to 0
	}
	
	unsigned t=0;
	char x;
	cout << endl;
	cout << "Insert text to count letter frequency. Press '$' to escape"<<endl;
	
	
	
	//'$' signals end of input
	while (x!='$') {
		cin >> x;
		cin >> noskipws;
		
		++t;		//increment letter cout
		
		if (x <= 90 && x >= 65) {
			x += 32; //no distinction between upper/lower case
			}
		
		if (x<=122 && x>= 97) {
			++freq[x-97];
		}
		else {
			++freq[26]; //not a letter
		}
	}
	for(int i=0; i<26; i++)    //print on screen.
	{
		
		cout << "\t"<<char(i+97)<<"\t: " <<freq[i]<< " of " << t-1 << endl;//do not count escape '$'
				
		cout << endl;
	}
	cout << "\t"<<"Other\t: "<<freq[26]-1<<" of " << t-1 << endl;

	

	
    return 0;
}


Topic archived. No new replies allowed.