Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Down here is the question and below it its answer( in case it might help ) . I want object oriented programming code for same
Down here is the question and below it its answer( in case it might help ) . I want object oriented programming code for same question.
#include#include #include #include using namespace std; int main( int argc, char* argv[] ) { if ( argc
Exercise 1 -Character Counter The goal of this laboratory session is to develop a small Console application that counts the number of occurrences of each character (byte value) in a given input file. The solution requires approx. 80 lines of code. As a simplification, we write just a main function to implement the character counting process. (Decomposing the problem into several smaller functions would normally be better, but we do not know enough about parameter passing in C++ at this stage, which is a prerequisite for function decomposition.) The Chair Counter main function must define five distinct parts: Check command line arguments and open an input file Declare two variables: an integer variable to count the total number of characters processed and an array of integers with 256 elements to count the character frequencies. The two variables must be properly initialized. Count the characters in the input file. A simple while-loop can do the trick. We use binary I/O. So, we need to use the get method to read a character from a file in binary mode. We can use the result as an index to increment the corresponding element in the character frequency array. Produce a console output by traversing the character frequency array. Skip entries with value 0. All printable entries (is graph (c) returns true if c s the value of the current index) must be printed as a normal character, whereas entries with no graphical representation must be printed as two-character hexadecimal numbers. This step requires a for-loop. You can convert an int value i to a char value c by char c i; (there is another way to achieve this in C/C++, but this approach works for now) Close the input file and terminate the main function Before you can start, you need to get a brief overview of the cctype character handling functions, the iostream standard output stream, the ifstream input file stream, and iomanip stream manipulators http://www.cplusplus.com/reference In order to build the program you need to understand the use of the cctype function is graphi the iomanip manipulators o dec print a number in decimal format
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started