C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 25th, 2012, 02:19 PM
rodrigsteve rodrigsteve is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 1 rodrigsteve User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 48 sec
Reputation Power: 0
General - Counting words, syllables, and sentences.

my goal is to build a program the counts the words, the syllables, and the sentences of an input.txt file, but for some reason, my code keeps failing.

keep in mind, I am very new to C++.
thanks for the help, in advance!

----------------------------------------------

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main ()
{
int wordCount, syllableCount, sentenceCount,
syllableTotal, sentenceTotal, wordTotal;
string phrase;
double index;

int x;
int i;
int aCount = 0;
int eCount = 0;
int iCount = 0;
int oCount = 0;
int uCount = 0;
int yCount = 0;

syllableCount = 0;
sentenceCount = 0;
wordCount = 0;
index = 206.835 - 84.6 * syllableCount/wordCount
- 1.105 * wordCount/sentenceCount;

cin >> phrase;


wordCount = phrase.size();
while (cin >> phrase)
{
if (phrase == "\0" || phrase == ".")
{
wordCount = phrase.at("\0" || ".");
wordTotal = wordTotal + wordCount;
}
}



while (cin >> phrase)
{
char character;

for (i=0; i < x; i++);
{
if (character == 'a' || character == 'A')
aCount++;
}

for (i=0; i < x; i++);
{
if (character == 'e' || character == 'E')
aCount++;
}

for (i=0; i < x; i++);
{
if (character == 'i' || character == 'I')
aCount++;
}

for (i=0; i < x; i++);
{
if (character == 'o' || character == 'O')
aCount++;
}

for (i=0; i < x; i++);
{
if (character == 'u' || character == 'U')
aCount++;
}

for (i=0; i < x; i++);
{
if (character == 'y' || character == 'Y')
aCount++;
}

syllableTotal =
syllableTotal+(aCount+eCount+iCount+oCount+uCount+ yCount);

}



while (cin >> phrase)
{
if (phrase == "." || phrase == "\n")
sentenceCount = phrase.at("." || "\n");
sentenceTotal = sentenceTotal + sentenceCount;
}


cout << "Words: " << wordTotal << "\n" << "Syllables: " << syllableTotal <<
"\n" << "Sentences: " << sentenceTotal << "\n" << "Legibility Index: "
<< index << endl;


return 0;
}

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > General - Counting words, syllables, and sentences.


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

© 2003-2014 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap