Ask C/C++ Expert


Home >> C/C++

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:

FILE * open_input_file (void) - Opens "input.dat" for reading.

char read_character (FILE *infile) - Reads one character from the input file.

intdetermine_ascii_value (char character) - Returns the ASCII value of the character passed into the function.

intis_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.

intnumber_lines (char character, intcurrent_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.

intis_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.

intnumber_vowels (char character, intcurrent_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.

intis_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.

intnumber_digits (char character, intcurrent_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.

intis_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.

intnumber_alphas (char character, intcurrent_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.

intis_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.

intnumber_lowers (char character, intcurrent_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.

intis_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.

intnumber_uppers (char character, intcurrent_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.

intis_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.

intnumber_spaces (char character, intcurrent_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.

intis_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.

intnumber_alnums (char character, intcurrent_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.

intis_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.

intnumber_puncts (char character, intcurrent_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.

void print_int (FILE *outfile, int number) - Prints an integer to an output file.

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.

A main function that does the following:
Opens an input file input.dat for reading;
Opens an output file output_stats.dat for writing all data generated by print_stats( );
Opens an output file output_ascii.dat for writing all ascii values of each character;
Checks to see if the files were opened successfully

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;

Prints the number of lines in the file to output_stats.dat;
Prints the number of vowels in the file to output_stats.dat;
Prints the number of digits in the file to output_stats.dat;
Prints the number of alpha characters in the file to output_stats.dat;
Prints the number of lowercase characters in the file to output_stats.dat;
Prints the number of uppercase characters in the file to output_stats.dat;
Prints the number of space characters in the file to output_stats.dat;
Prints the number of alphanumeric characters in the file to output_stats.dat;
Prints the number of punctuation characters in the file to output_stats.dat;
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

V. Submitting Assignments:

1. Using Blackboard Learn https://learn.wsu.edu/webapps/login/ submit your assignment to your TA through the link ending with "-LAB". Under the "Content" link navigate to the "Programming Assignment Submissions" folder and upload your solutions to the appropriate "Assignment" space. You must upload your solutions as _pa3.zip by the due date and time.

2. Your .zip file should contain your one header file (a .h file), two C source files (which must be .c files), and project workspace. Delete the debug folders before you zip the project folder.

3. Your project must build properly. The most points an assignment can receive if it does not build properly is 65 out of 100.

V. Grading Guidelines:

This assignment is worth 100 points. Your assignment will be evaluated based on a successful compilation and adherence to the program requirements. We will grade according to the following criteria:

Proper program comments

• There should be a header block of documentation at the top of the file
• Each function should have a header block of documentation
• Each algorithmic step should be documented
• You should use proper indentation and spacing

Proper function definitions

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M91642694
  • Price:- $75

Priced at Now at $75, Verified Solution

Have any Question?


Related Questions in C/C++

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As