Hi, everyone. I'm completely new to the forum and C++.
This is my forth program for the c++ programming class. I don't have a clue what i should do to get my hand on this program.
here it is:
_________
You are to write a C++ program that will scan a text file and do some elementary analysis that might indicate how difficult the text is to read. In particular, your program will:
1. Determine the average length of all the words in the text
2. Find the longest word in the text and display it
3. Determin the average number of words in each sentence
4. Find the longest sentence and display it
"Mr." is not an actual word.
You are allowed to use while, if , else condition only, no For condition
_________
This is what I got so far, I don't know what I should do next.
Code:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main()
{
string fileName;
string getout;
string words;
int word_count;
string space = " ";
ifstream infile;
bool run = true;
while(run)
{
cout << "Please insert the file name: ";
cin >> fileName;
infile.open(fileName.c_str());
if (infile.fail())
{
cout << fileName << " cannot be found." << endl;
cout << "Please try again, do you want to quit? (y/n)";
cin >> getout;
if (getout == "y")
{
cout << "You decide to stop the program \n";
return 0;
}
}
else
{
while (run)
{
cin words;
____help___Please____
}
}
}
return 0;
}
Thanks,