Question
This assignment tests your ability to write C programs that handle keyboard input, formatted console output, and input/output with text files. The program also tests
This assignment tests your ability to write C programs that handle keyboard input, formatted console output, and input/output with text files. The program also tests your ability to write fairly simple logic as well as some of the ctype.h functions like isalpha and tolower.
This program will input from the user two letters where the second letter > the first letter. The letters can be input in either upper or lower case. Data verify that both characters are letters and that second > first using code like the following.
prompt the user
do {
input both characters
}while(!isalpha(first)||!isalpha(second)||
tolower(first)>tolower(second));
Use scanf to input the characters. Recall that when inputting non-string, the variables when passed to scanf must be preceded by &. For characters to input correctly, add a blank space before %c as in scanf(" %c", &first); or scanf(" %c %c", &first, &second);
The program will also either input two file names (an input file and an output file) as strings or hardcode the file names in string variables. The reason for the string variables is to reuse them in both fopen and later printf instructions.
Open both files, the first as a read file and the second as a write file. The program will then input a file character-by-character using a while loop and output those letters that fall between the two characters (inclusively) to an output file, along with all white space and punctuation marks but no digits. As the input letters can be upper or lower case, we want to ensure that a files character is handled properly whether upper or lower case. That is, if the letters input from the user are b and p and the files character is either d or D, it should be output. Use toupper or tolower to compare first/second and the files character
In addition to outputting all of the characters that fall between the two input chars inclusively, is white space or a punctuation mark, count each input character, each output character, and the number of letters that were not output (dont bother to count the digits). After exiting the while loop, close both files and compute the difference in size between the output file and input file as a percentage using the formula output_size / input_size * 100. The variables input_size and output_size should be ints and that would make the above division an int division requiring that you perform some kind of casting to make one value a double (without this, you will likely wind up with a value of 0.0 since input_size > output_size). Output a short report to the console window (using printf statements) that lists the input file name, output file name (this is why you want to store the file names in string variables, whether you input them from the user or hardcode them in the program is up to you), size of input file, size of output file, number of letters not output, and percentage file change.
See the example output on the next page of this assignment. There are two input files on the website. Download them and run your program on the first using letters b and p (or B and P), comparing your results to the results on the next page. Once your program is properly debugged, run your program on the second input using e and x. Copy and paste the output from the console window (the printf statements) and copy the output text file to your .c file in comments at the bottom. Submit your program by email to foxr@nku.edu by the specified due date and time. Only email the .c (.cpp) file (which should include the console output and the output file). Note: if your file sizes are off by 1, dont worry about it. This happens when running on different platforms.
Output:
Enter the two letters: b p
Input file name: p1in1.txt
Output file name: p1out1.txt Input file size: 158
Output file size: 111
Letters skipped: 47
Difference in size: 70.25%
Created text file (message1output.txt):
Infomion i no knoledge;
knoledge i no idom,
idom i no h,
h -- i no be,
be i no loe, l
oe i no mic.
MIC i he BE!
Can someone help me with this assignment!!!
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