CptS 121 Program Development & Design program design in C, C/C++ Programming

Assignment Help:
Write a program that performs character processing on 10 characters read in from a file, and writes the results to output files. Do NOT use loops or arrays to solve this problem.
NOTE: You may NOT use the standard library functions found in .

Your program should define the following functions:
* (2 pts) FILE * open_input_file (void) — Opens "input.dat" for reading.
* (2 pts) char read_character (FILE *infile) — Reads one character from the input file.

* (2 pts) int determine_ascii_value (char character) — Returns the ASCII value of the character passed into the function.

* (4 pts) int is_line (char character) — Determines if the character is a newline, if the character is a newline a 1 is returned otherwise a 0 is returned.
Make sure that you #define two constants NEWLINE and NOT_NEWLINE as 1 and 0, respectively. Return the #defined constant.
* (4 pts) int number_lines (char character, int current_number_lines) — Determines if the character passed into the function indicates the end of a line (use is_line ( )),
if so the function adds 1 to the current_number_lines and returns the value; otherwise it returns the current_number_lines without any modification.

* (4 pts) int is_vowel (char character) — Determines if the character is a vowel (note: the character may be lower or upper case), if the character is a vowel a 2 is returned otherwise a 0 is returned.
Make sure that you #define two constants VOWEL and NOT_VOWEL as 2 and 0, respectively. Return the #defined constant.
* (4 pts) int number_vowels (char character, int current_number_vowels) — Determines if the character passed into the function is a vowel (use is_vowel ( )),
if so the function adds 1 to the current_number_vowels and returns the value; otherwise it returns the current_number_vowels without any modification.

* (4 pts) int is_digit (char character) — Determines if the character is a digit (i.e. ''0'' - ''9''), if the character is a digit a 3 is returned otherwise a 0 is returned.
Make sure that you #define two constants DIGIT and NOT_DIGIT as 3 and 0, respectively. Return the #defined constant.
* (4 pts) int number_digits (char character, int current_number_digits) — Determines if the character passed into the function is a digit (use is_digit ( )),
if so the function adds 1 to the current_number_digits and returns the value; otherwise it returns the current_number_digits without any modification.

* (4 pts) int is_alpha (char character) — Determines if the character is an alpha character (i.e. ''a'' - ''z'', ''A'' - ''Z''), if the character is an alpha character a 4 is returned otherwise a 0 is returned.
Make sure that you #define two constants ALPHA and NOT_ALPHA as 4 and 0, respectively. Return the #defined constant.
* (4 pts) int number_alphas (char character, int current_number_alphas) — Determines if the character passed into the function is an alpha character (use is_alpha ( )),
if so the function adds 1 to the current_number_alphas and returns the value; otherwise it returns the current_number_alphas without any modification.

* (4 pts) int is_lower (char character) - Determines if the character is a lowercase character, if the character is a lowercase character a 5 is returned otherwise a 0 is returned.
Make sure that you #define two constants LOWER and NOT_LOWER as 5 and 0, respectively. Return the #defined constant.
* (4 pts) int number_lowers (char character, int current_number_lowers) — Determines if the character passed into the function is a lowercase character (use is_lower ( )),
if so the function adds 1 to the current_number_lowers and returns the value; otherwise it returns the current_number_lowers without any modification.

* (4 pts) int is_upper (char character) - Determines if the character is an uppercase character, if the character is an uppercase character a 6 is returned otherwise a 0 is returned.
Make sure that you #define two constants UPPER and NOT_UPPER as 6 and 0, respectively. Return the #defined constant.
* (4 pts) int number_uppers (char character, int current_number_uppers) — Determines if the character passed into the function is a uppercase character (use is_upper ( )),
if so the function adds 1 to the current_number_uppers and returns the value; otherwise it returns the current_number_uppers without any modification.

* (4 pts) int is_space (char character) - Determines if the character is a whitespace character (i.e. space '' '', form feed ''\f'', new-line ''\n'', carriage return ''\r'', horizontal tab ''\t'', and vertical tab ''\v''),
if the character is a whitespace character a 7 is returned otherwise a 0 is returned. Make sure that you #define two constants WHITESPACE and NOT_WHITESPACE as 7 and 0, respectively.
Return the #defined constant.
* (4 pts) int number_spaces (char character, int current_number_spaces) — Determines if the character passed into the function is a space character (use is_space ( )),
if so the function adds 1 to the current_number_spaces and returns the value; otherwise it returns the current_number_spaces without any modification.

* (4 pts) int is_alnum (char character) - Determines if the character is an alpha or digit character, if the character is an alpha or digit character a 8 is returned otherwise a 0 is returned.
Make sure that you #define two constants ALNUM and NOT_ALNUM as 8 and 0, respectively. Return the #defined constant.
* (4 pts) int number_alnums (char character, int current_number_alnums) — Determines if the character passed into the function is an alphanumeric character (use is_alnum ( )),
if so the function adds 1 to the current_number_alnums and returns the value; otherwise it returns the current_number_alnums without any modification.

* (4 pts) int is_punct (char character) - Determines if the character is a punctuation character (i.e. ''.'', ''!'', '','', etc.) if the character is a punctuation character an 9 is returned otherwise a 0 is returned.
Make sure that you #define two constants PUNCT and NOT_PUNCT as 9 and 0, respectively. Return the #defined constant.
* (4 pts) int number_puncts (char character, int current_number_puncts) — Determines if the character passed into the function is a punctuation character (use is_punct ( )),
if so the function adds 1 to the current_number_puncts and returns the value; otherwise it returns the current_number_puncts without any modification.

* (3 pts) void print_int (FILE *outfile, int number) — Prints an integer to an output file.
* (3 pts) void print_stats (FILE *outfile, char header[ ], int number) — Prints a line like the following:
Number Vowels: 45

where "Number of vowels" is the string represented by the variable header and 45 is represented by number.

bullet
(10 pts) A main function that does the following:
bullet
Opens an input file input.dat for reading;
bullet
Opens an output file output_stats.dat for writing all data generated by print_stats ( );
bullet
Opens an output file output_ascii.dat for writing all ascii values of each character;
bullet
Checks to see if the files were opened successfully
bullet
Reads one character at a time from the input file (input.dat), until all 10 characters have been read; For each character that is read in, its corresponding ASCII value should be printed to the output file, output_ascii.dat; Hint: use the print_int ( ) function to print the ASCII values;
bullet
Prints the number of lines in the file to output_stats.dat;
bullet
Prints the number of vowels in the file to output_stats.dat;
bullet
Prints the number of digits in the file to output_stats.dat;
bullet
Prints the number of alpha characters in the file to output_stats.dat;
bullet
Prints the number of lowercase characters in the file to output_stats.dat;
bullet
Prints the number of uppercase characters in the file to output_stats.dat;
bullet
Prints the number of space characters in the file to output_stats.dat;
bullet
Prints the number of alphanumeric characters in the file to output_stats.dat;
bullet
Prints the number of punctuation characters in the file to output_stats.dat;
bullet
Closes all opened files;

Sample Execution:

The following sample session demonstrates how your program should work, although your program is only required to read in 10 characters.
Assuming input.dat stores the following characters:
CptS 121 is really fun!

Your program should write the following to output_ascii.dat:
67
112
116
83
32
49
50
49
32
105
115
32
114
101
97
108
108
121
32
102
117
110
33
10

Your program should write the following to output_stats.dat:
Number Lines: 1
Number Vowels: 4
Number Digits: 3
Number Alphas: 15
Number Lowers: 13
Number Uppers: 2
Number Spaces: 5 -- Including newline (''\n'')
Number Alnums: 18
Number Puncts: 1

Related Discussions:- CptS 121 Program Development & Design program design in C

Operator overloading, write aprogram in c++ to overload +,-,=,++ operator ...

write aprogram in c++ to overload +,-,=,++ operator using unary and friend function in a single program

Password Validation Prgram in C++, Create a .cpp program that verifies the ...

Create a .cpp program that verifies the strength of a password that a user is entering is strong (complex/secure) enough. In the main area of the program, prompt the user to enter

.C# mouse and maze program, .Create a Csharp solution that will show a maze...

.Create a Csharp solution that will show a maze in the user interface and will show a mouse walking through the maze attempting to locate the exit door (the cheese).

How to create a data file, How to Create A Data File? A data file shoul...

How to Create A Data File? A data file should be created before it can be processed. A stream-oriented data file is able to be created in two ways. One is to create the file st

Algorithm, Write a algorithm to explain the processof wakingbup in morning

Write a algorithm to explain the processof wakingbup in morning

Get linux caller id to work with usb modem on ubuntu, Project Description: ...

Project Description: I am seeking someone who can make this modem work with Linux Caller ID on Ubuntu present stable version. Skills required are C Programming, Python

Palindrome, A palindrome is a string that reads the same from both the ends...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

Develop opencv tracking, Help me evaluate suitable OpenCV filters to get an...

Help me evaluate suitable OpenCV filters to get an inital working tracking algorithm. In this case it's objects moving on water (sea) and since I have very limited OpenCV knowledge

Game, how to make a game

how to make a game

Develop a windows application to show computer hardware, - But with less fe...

- But with less features and more user-friendly (particularly for non-tech savvy users). - Software needed having a left menu with links (no pictures required) for every hardwar

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd