---------------------- I used Visual Studio 2013, C++ Language, Console Application ----------------------
---------------------- OUTPUT ----------------------
-------------------- CODE --------------------
-------------------- TextReader.cpp --------------------
#include "stdafx.h"
#include <string>
#include <iostream>
#include <fstream>
using namespace std;
struct variables
{
int words;
int characters;
int paragraphs;
};
class TextUtil
{
public:
//structure will hold the word,characters and
paragraphs count
struct variables v;
//readFile function read the text file and count
characters,words and pargraphs present.
void readFile();
};
void TextUtil::readFile()
{
ifstream file("input_file.txt");
if (file.is_open())
{
//initialise local variables
string word;
int wordCount = 0, characterCount =
0, paragraphCount = 0;
//Read the text file word by word,
does'nt include space
while (file >> word)
{
//Each iteration
we will get a word, increment wordCount by 1
wordCount++;
//get the word
length each time and add to characterCount
characterCount
+= word.length();
}
//Once the file is fully read,
close the file.
file.close();
//Open the same file to
count the paragraph
file.open("input_file.txt");
string line,temp;
//From the text file get line by
line
while (getline(file, line))
{
//I am counting
paragraph count based on empty line.
//If line
variable is empty and temp variable contains old line variable with
some data then means it will be a paragraph.
//I made this
comparison to eliminate consecutive empty line not to be
counted.
if (line == ""
&& temp != "")
{
paragraphCount++;
}
//On each
iteration set the current line to temp.
temp =
line;
}
//Set all values to
struct variable.
v.characters =
characterCount;
v.words = wordCount;
v.paragraphs =
paragraphCount;
}
else
{
cout << "File not found"
<< endl;
}
}
int main()
{
//Create object of class TextUtil called tu
TextUtil tu;
//Read text file
tu.readFile();
//Print the output.
cout << "Character(s) : " <<
tu.v.characters << endl;
cout << "Word(s) : " << tu.v.words
<< endl;
cout << "Paragraph(s) : " <<
tu.v.paragraphs << endl;
//Pause the console to view the output.
system("pause");
return 0;
}
C++ please Project: Working with Text Write an object-oriented program the performs the following tasks: ....
Object Oriented Programming Please write the code in C++ Please answer the question in text form 9.5 (complex Class) Create a class called complex for performing arithmetic with complex numbers. Write a program to test your class. Complex numbers have the form where i is V-I Use double variables to represent the private data of the class. Provide a constructor that enables an object of this class to be initialized when it's declared. The constructor should contain default values in...
In this lab, you will need to implement the following functions in Text ADT with C++ language(Not C#, Not Java please!): PS: The program I'm using is Visual Studio just to be aware of the format. And I have provided all informations already! Please finish step 1, 2, 3, 4. Code is the correct format of C++ code. a. Constructors and operator = b. Destructor c. Text operations (length, subscript, clear) 1. Implement the aforementioned operations in the Text ADT...
The purpose of this assignment is to develop solutions that perform File IO and objects. Problem specifications are shown below with my changes in blue. 1. File Previewer Write a program that asks the user for the name of a text file. The program should display the first 10 lines of the file on the screen. If the file has fewer than 10 lines, the entire file should be displayed along with a message indicating the entire file has been...
*Java* Given the attached Question class and quiz text, write a driver program to input the questions from the text file, print each quiz question, input the character for the answer, and, after all questions, report the results. Write a Quiz class for the driver, with a main method. There should be a Scanner field for the input file, a field for the array of Questions (initialized to 100 possible questions), and an int field for the actual number of...
Using an object-oriented approach, write a program to read a file containing movie data (Tile, Director, Genre, Year Released, Running Time) into a vector of structures and perform the following operations: Search for a specific title Search for movies by a specific director Search for movies by a specific genre Search for movies released in a certain time period Search for movies within a range for running time Display the movies on the screen in a nice, easy to read...
For a C program hangman game: Create the function int play_game [play_game ( Game *g )] for a C program hangman game. (The existing code for other functions and the program is below, along with what the function needs to do) (Also the link to program files (hangman.h and library file) is below the existing code section. You can use that to check if the code works) What int play_game needs to do mostly involves calling other functions you've already...
SCREENSHOTS ONLY PLEASE!!! DON'T POST ACTUAL CODE PLEASE LEAVE A SCREENSHOT ONLY! ACTUAL TEXT IS NOT NEEDED!!! mystring.h: //File: mystring1.h // ================ // Interface file for user-defined String class. #ifndef _MYSTRING_H #define _MYSTRING_H #include<iostream> #include <cstring> // for strlen(), etc. using namespace std; #define MAX_STR_LENGTH 200 class String { public: String(); String(const char s[]); // a conversion constructor void append(const String &str); // Relational operators bool operator ==(const String &str) const; bool operator !=(const String &str) const; bool operator >(const...
I NEED HELP WITH DEBUGGING A C PROGRAM! PLEASE HEAR ME OUT AND READ THIS. I just have to explain a lot so you understand how the program should work. In C programming, write a simple program to take a text file as input and encrypt/decrypt it by reading the text bit by bit, and swap the bits if it is specified by the first line of the text file to do so (will explain below, and please let me...
in c++ please Page 1 of 3 (PRO) Project Assignment Instructions Last Charged: 6/1/2020 Read and follow the directions below carefully and perform the steps in the order listed. You will be solving one program as instructed and turning in your work electronically via an uploaded file within Eagle Online/Canvas and copy & paste the program to the Text Entry box as well. Make sure and check your work prior to uploading the assignment (NOTE: For Steps 1 & 2...
hey, this is a filei/o homework. um please show me how to do this (im using ONLY arraylist for the first part so please continue on that) i have put my work please fix some mistakes and continue on it. the file is named “tools.txt” its a text document file that i savedin the netbeansprojects file. um pleas euse netbeans and show me the output afterwards, make it simple and continue on what i have worked on whilw fixing some...