Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Problem solving and debugging. Linux redirection to read data from a file. Use o

ID: 3850348 • Letter: P

Question

Problem solving and debugging.

Linux redirection to read data from a file.

Use of conditional loop (while).

Data File Description
A data file for this exercise will consist of several lines of text that form sentences. The text may include letters, punctuation marks, and/or digits. Each sentence will be terminated with either a period (.), an exclamation mark (!), or a question mark (?).

Design and implement a complete C++ program that will

using Linux redirection, read the contents of the file and

compute the average number of letters per sentence in the file

count the number of digits in the file

display the average with a label and 3 digits to the right of the decimal

display the digit count with a label




NOTES:

Make sure you choose enough test data to ensure that your program meets all the requirements.

If you use any library functions in your program make sure you include the appropriate header file(s).

Sample terminal session:
[keys]$ more data4eight
What is Earth Day? Earth Day is
celebrated annually on April 22 to demonstrate support for
environmental protection. It was first marked
in 1970 and is coordinated globally by the
Earth Day Network. More than
193 countries participate each year.
[keys]$ g++ ex08.cpp
[keys]$ ./a.out < data4eight

Average # of letters per sentence is 48.250
Total # of digits in the file is 9

**EXTRA NOTES:
-This does NOT use fstream. Input will be taken through cin.
-String cannot be used. The program can be created without it.
-USE A WHILE LOOP.
-Do not use functions, arrays, or strings.

Part of my program:

#include <iostream>
#include <cctype>
using namespace std;

int main()
{

cin >> data;
while (cin)
{

cin >> data;
}


return 0;
}

Explanation / Answer

Let d(x, y) represent the performing distance between the bit
strings x and y of length n. Then:
(i) d(x, y) zero for all x, y
(ii) d(x, y) = zero if and provided that x = y
(iii) d(x, y) = d(y, x) for all x, y
(iv) d(x, y) d(x, z) + d(z, y) for all x, y, z.
Proof: Properties (i), (ii), and (iii) follow now from the definition of
the performing distance. To prove (iv), we tend to use the very fact that d(x, y) is that the variety
of changes of bits needed to vary x into y. Note that for each string z of
length n the quantity of changes required to vary x into y doesn't exceed the
number of modifications needed to vary x into z and to then change z into y.
How will the performing distance be employed in decoding? specially, suppose
that once a codeword x from a code C is distributed, the bit string y is received.
If the transmission was error-free, then y would be a similar as x. however if errors
were introduced by the transmission, as an example by a loud line, then y isn't
the same as x. however will we tend to correct errors, that is, however will we tend to recover x?
One approach would be to reckon the performing distance between y
and each of the codewords in C. Then to rewrite y, we tend to take the codeword
of minimum performing distance from y, if such a codeword is exclusive. If the
distance between the nearest codewords in C is giant enough and if sufficiently
few errors were created in transmission, this codeword ought to be x, the codeword
sent. this kind of secret writing is termed nearest neighbor secret writing.
Example five Use nearest neighbor secret writing to see that code word
was sent from the code C = if 0110 is received.
Solution: we tend to initial notice the gap between 0110 and every of the codewords.
We find that
d(0000, 0110) = 2
d(1110, 0110) = 1
d(1011, 0110) = 3.
Since the nearest codeword to 0110 is 1110, we tend to conclude that 1110 was the
codeword sent.
Will nearest neighbor secret writing turn out the foremost seemingly codeword that was
sent from a binary string that was received? it's not arduous to examine that it'll
if every bit sent has a similar chance p of being received incorrectly and
p &lt; 1/2. we tend to decision a transmission with this property a binary isobilateral
channel.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote