ELET2300 Assignment3 SubmityourprogramthroughBlackboard–Nolatesubmissions! Donotuploadthebooks,onlyyourmain.cppfile...

1 answer below »
I have attached the assignment



ELET2300 Assignment3 SubmityourprogramthroughBlackboard–Nolatesubmissions! Donotuploadthebooks,onlyyourmain.cppfile ThetaskistowriteaprogramusingthecomputerlanguageC++thatwillhelpus contrasttwohumanlanguages:EnglishandFrench. Tothisend,wewillanalyzetwolanguageversionsofthebook"OntheOriginof Species",byCharlesDarwin.Thebookisinthepublicdomainandcanberetrievedin eitherlanguagefromtheGutenbergproject: http://www.gutenberg.org/cache/epub/1228/pg1228.txt http://www.gutenberg.org/cache/epub/14158/pg14158.txt Downloadthefilestoyourcomputer.Thefilesareinplaintext.Haveapeekbyopening eachfilewitheitherNotepadorWordpad.ThenwriteaC++programthatworksinthe followingway: 1.DefineaC++functionwiththenameevaluateBook.Thefunctionreceivesasone argumentthenameofthefiletobeprocessed(i.e.,thebook'sfile).Sothatifyoupassthe Englishversion,wewillseetheresultsonlyforthatlanguage. 2.FunctionevaluateBookopensthefile,readsit,analyzesit,andprintstheanswertothe followingquestions: 1. Whatitthetotalnumberoftextlinesinthefile? 2. Whatitthenumberoftextlineswithoutanylower-caseletter?Toanswerthis question,writeandcallthefunctiontestLowerCase. 3. Whatitthenumberoftextlineswithoutanynumber?Toanswerthisquestion, writeandcallthefunctiontestNumber. 4. Whatisthetotalnumberofvisiblecharacters(so,excludinginvisiblecodessuch as'\n')?Toanswerthisquestion,writeandcallthefunctioncountCharacters. 5. Whatisthetotalnumberofletters(i.e.,excludingsymbols,numbers,etc.)?To answerthisquestion,writeandcallthefunctioncountLetters. 6. Howmanytimeseachofthefollowingpunctuationsymbolsappear:comma, period,doublequotes,singlequotes? 7. Whatisthemostpopularletter(regardlessofitscase)? 8. Theword"et"inFrenchmeans"and".Howmanytimesdoesthiswordappear? Thefunctionshouldsearchforbothwords,sothatifyoupasstheEnglish version,thecountfor"et"willbelikelyzero.Also,ignorethecase,butdonot countamatchingifpartofanotherword,suchas"Andrew". 3.YouneedtowritethefunctionstestLowerCase,testNumber,countCharacters, countLetters,whichyouwillcallfromevaluateBook.Thefunction'sargumentforeachof themisthecurrentlinefromthetextbookthatisbeingprocessed(asastring).The functionthenmustreturnabooleanwiththeresultofthetest. 4.CallthefunctionevaluateBookfrommain,firstwiththeEnglishversionpg1228.txt andthenwiththeFrenchversionpg14158.txtsothatwecancontrasttheresultsfor eachlanguageonthescreen. YoumustuseonlytheC++instructionsthatwehavecoveredsofarinclass. Notes: - Theprogramthatyouturninmustbeyouroriginalandindividualwork.While youareallowedtodiscusstheprogramassignmentsingeneraltermswithothers, youarenotallowedtosharedetailsoftheactualsolution(s)orprogramcode withanybodyexcepttheinstructor. - Turninginacopyofsomeoneelse'sprogram,evenacopywithextensivechanges madetoit,orreceivinganyunauthorizedassistanceisaveryseriousoffenseinthis course. - Asneeded,youcanbeaskedtoexplainyoursolutioninpersonanytimethroughout thesemester. - Anautomatedplagiarismcheckermayscanprogramsatanytimeduringthe semester.Thesechecksmayincludeallassignments,quizzesandexams. - Onlysubmityoursourcecode(.cpp).Thismustbedoneonorbeforetheduedate throughBlackboard.Nolatesubmissions.Blackboardwillautomaticallyclosethe submissionpagerightafterthedeadline. - Yourprogrammustincludecommentsexplainingyourstepsandmustbeproperly formatted(seeProgram_Style_Guidelines.pdfinBlackboard). - Insertthefollowingblockatthetopofyourfilewithyourinformation: /∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗ ∗ELET2300
 ∗ProgrammingAssignment *Compilername ∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗/
Answered Same DayApr 09, 2021

Answer To: ELET2300 Assignment3 SubmityourprogramthroughBlackboard–Nolatesubmissions!...

Aditya answered on Apr 09 2021
144 Votes
// This program should give you a good idea of how to solve Assignment #3
//
// It reads the file "pg1228.txt" and prints the number of times
// the character '1' or '2' appears in the text corpus
#include
#include
#includ
e
#include
#include
using namespace std;
// user-defined function, which will take care of the text analysis
bool testLowerCase(string book_line)
{
int z =0;
string s = book_line;
int n = s.length();
char char_array[n + 1];
strcpy(char_array, s.c_str());
for(int i=0;i {
if (islower(char_array[i]))
{
z++;
}
}
if(z>0)
{
return true;
}
else
{
return false;
}
}
bool testNumber(string book_line)
{
int z =0;
string s = book_line;
int n = s.length();
char char_array[n + 1];
strcpy(char_array, s.c_str());
for(int i=0;i {
if (isdigit(char_array[i]))
{
z++;
}
}
if(z>0)
{
return true;
}
else
{
return false;
}
}
int countLetter(string book_line)
{
int z = 0;
string l = book_line;
int n = l.length();
char char_array[n+1];
strcpy(char_array,l.c_str());
for(int i=0;i {
if (isalpha(char_array[i]))
{
z++;
}
}
return z;
}
int countCharacters(string book_line)
{
int z =0;
string l = book_line;
int n = l.length();
char char_array[n+1];
strcpy(char_array,l.c_str());
for(int i=0;i {
if (isspace(char_array[i]))
{
z++;
}
}
z = n-z;
return z;
}
int countComma(string book_line)
{
int z =0;
string l = book_line;
int n = l.length();
char char_array[n+1];
strcpy(char_array,l.c_str());
for(int i=0;i {
if (char_array[i] == ',')
{
z++;
}
}
return z;
}
int countPeriod(string book_line)
{
int z =0;
string l = book_line;
int n = l.length();
char char_array[n+1];
strcpy(char_array,l.c_str());
for(int i=0;i {
if (char_array[i] == '.')
{
z++;
}
}
return z;
}
int countDoubleQuotes(string book_line)
{
int z =0;
string l = book_line;
int n =...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here