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

Write a program that outputs to a file (called out.txt) the content of an input

ID: 3536538 • Letter: W

Question

Write a program that outputs to a file (called out.txt) the content of an input file (called in.txt)

and in addition it outputs to the file out.txt the following information about the content of the file

in.txt :

Number of lines in file in.txt

Number of digits in file in.txt

Number of letters in file in.txt

Number of capital letters in file in.txt

Number of capital A%u2019s in file in.txt

Number of capital B%u2019s in file in.txt

Number of capital C%u2019s in file in.txt

Number of capital D%u2019s in file in.txt

Number of capital E%u2019s in file in.txt

Number of capital F%u2019s in file in.txt

Number of capital G%u2019s in file in.txt


Note: You can create infile.txt using MS Word and make sure to include in the file sufficient

data that can be used to test well your code. Also, use an array to hold the number of A%u2019s, B%u2019s,

%u2026G%u2019s. in the file.

Explanation / Answer

#include<iostream.h>

#include<fstream.h>

void main()

{

int a=0,b=0,c=0,d=0,e=0,f=0,g=0,cap=0,digit=0,lines=0,letter=0;

fstream file,file1;

file.open("in.txt");

file1.open("out.txt");

int i;

char in[100];

while(file!=eof)

{

file.read((char*)&a,sizeof(a));

file1.write((char*)&a,sizeof(a));

for(i=0;i<100;i++)

{

if (a[i]==' ')

lines++;

if(a[i]>=0 && a[i]<=9)

digit++;

if(a[i]>='a' && a[i]<='z' && a[i]>='A' && a[i]<='Z')

letter++;

if(a[i]>='A' && a[i]<='Z')

cap++;

if(a[i]=='A')

a++;

if(a[i]=='B')

b++;

if(a[i]=='C')

c++;

if(a[i]=='D')

d++;

if(a[i]=='E')

e++;

if(a[i]=='F')

f++;

if(a[i]=='G')

g++;

}

}

file1.write((char*)&lines,sizeof(lines));

file1.write((char*)&digit,sizeof(digit));

file1.write((char*)&letter,sizeof(letter));

file1.write((char*)&a,sizeof(a));

file1.write((char*)&b,sizeof(b));

file1.write((char*)&c,sizeof(c));

file1.write((char*)&d,sizeof(d));

file1.write((char*)&e,sizeof(e));

file1.write((char*)&f,sizeof(f));

file1.write((char*)&g,sizeof(g));

file.close();

file1.close();

}

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