x.Hming problems with this program and here are my instructions and any feedback
ID: 3618845 • Letter: X
Question
x.Hming problems with this program and here are my instructions and any feedback would be greatly appreciated...Write a program that reads a text file and counts the characters in each line. The program should display the line number and the length of the shortest and longest lines in the file, as well as the average number of characters per line.
#include <iostream>
#include <fstream>
#include <string>
#include <cassert>
using namespace std;
bool characterCount(char);
int main ()
{
//Describe the program to the user
cout << "This program reads a text file and counts the characters in each line!" << endl;
//INPUT SECTION
//Input the file
cout << "Enter the name of the input file: ";
char inputFilename[80];
int i;
cin.getline(inputFilename, 80);
//Open an input stream to the input file
//Establish a connection
ifstream fin;
//Check for success
fin.open(inputFilename);
//Implementation of the input file
//Declare variables
int count = 0, sum = 0;
char reading;
//For statemen to calculate
for(;;)
{
//Read a value from file
fin >> reading;
//If eof, quit
if (fin.eof()) break;
if (characterCount(reading))
//Update the count
count++;
}
//OUTPUT SECTION
//output the file
cout << "Enter the name of the output file: ";
char outputFilename[80];
cin >> outputFilename;
//Open an output stream to the output file
ofstream fout;
fout.open(outputFilename);
//Check for success
asset(fout.is_open());
//Write results to file
//Close the stream
fout.close());
cout << "Processing complete!" << endl;
//Return a value
return 0;
}
bool characterCount(char in)
{
bool value = false;
switch (in)
{
case 'a':
case 'A':
case 'b':
case 'B':
case 'c':
case 'C':
case 'd':
case 'D':
case 'e':
case 'E':
case 'f':
case 'F':
case 'g':
case 'G':
case 'h':
case 'H':
case 'i':
case 'I':
case 'j':
case 'J':
Explanation / Answer
please rate -thanks this counts everything but spaces, and enters #include #include #include #include using namespace std; int characterCount(string); int main () { //Describe the programto the user coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.