Actually i m having course work on this topic . so it would be useful if i can get the code.
Where can i get C++ code for SMOG grade?
1. Count off 10 consecutive sentences near the beginning, in the middle, and near the end of the text.
2. From this sample of 30 sentences, circle all of the words containing three or more syllables (polysyllabic), including repetitions of the same word, and total the number of words circled.
3. Estimate the square root of the total number of polysyllabic words counted. This is done by finding the nearest perfect square, and taking its square root.
4. Finally, add a constant of three to the square root. This number gives the SMOG grade, or the reading grade level that a person must have reached if he or she is to fully understand the text being assessed.
Now, if people give you the code you'll never learn anything!
You would need to design a form for someone to enter the text into, or have them save it as a plain text files (TXT) and then write your program to
OPEN the file
PARSE the text
LOOK for words with three syllables (this one is not easy)
Do the math
Return the results.
As an alternative, YOU manually look at the text, find the number of 3 syable words and then enter this as a DATA INPUT
Then you do that math.
That math isn't that hard! There are square root functions.
The math is easy, you can tell the program to look at the actual number, the number +1 or -1, obtain the SQR root, add 3 to this.
It's not hard at all.
Now, getting a program to parse a page of text and to determine 3 syllable words, that's more difficult and involves creating a data base of such words or teaching it to take words apart into sylables.
That's a bit of a tough order! Not impossible, but a tough order!
The other way probably only uses a few fields for inputting data, then doing the math and displaying an aswer.
Probably no more than 40 lines of code, a zillion semi colons and {} brackets.
God, I hate C!
Probably have to include some math library at the top header.
God, I hate C!
This can probably be done with 10 lines of code in VB.
Did they ever put an INPUT function in C or do you still have to get it character by character using a loop?
A VB example
On a blank form drag over 3 labels, one Text box and a push button
label1.caption="Enter total number of 3 syllable words:"
label2.caption="SMOG results"
Drag a push button
Select the option for a button press and write the code.
label3.caption = CINT(SQR(VAL(text1.text)))+3
When you enter a the number of 3 sylable words into the text box and press the push button (or use a carriage return in the Text Box and foget the button)
it does the math.
It rounds off the SQUARE root of the inputted value and returns an integer which is added to 3.
Now go do that in C++ in 40 words or less!
I rounded off to the next highest integer you can make it the lower integer by replacing CINT with INT
Go try all this in C, which doesn't have all that many "library" functions!
Reply:What do you mean as in SMOG? I'm learning c++ right now
baby breath
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment