Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien 4.2 TrustPilot
logo-home
Examen

Exam (elaborations) COS3711 Assignment 1 (COMPLETE GUIDELINE) 2025

Note
-
Vendu
-
Pages
13
Qualité
A+
Publié le
15-04-2025
Écrit en
2024/2025

Exam (elaborations) COS3711 Assignment 1 (COMPLETE GUIDELINE) 2025

Établissement
Cours









Oups ! Impossible de charger votre document. Réessayez ou contactez le support.

Livre connecté

École, étude et sujet

Établissement
Cours

Infos sur le Document

Publié le
15 avril 2025
Nombre de pages
13
Écrit en
2024/2025
Type
Examen
Contenu
Questions et réponses

Sujets

Aperçu du contenu

COS3711 Assignment 1 (COMPLETE GUIDELINE) 2025 Course

· Advanced Programming (COS3711)

Question 1 Write a console application that can be run from the command
line using the following forms: count // run without any parameters count //
pass one file name count fileT // pass more than one file name count –a –b
fileT // pass flags to change behaviour count –ab –c // pass flags in an
alternative way If no arguments are provided, then print a message
describing what arguments should be included. The application should, using
regular expressions, count the number of occurrences of each of the
following in the text files given. • If the –a flag is set, count the number of
words longer than 4 characters that start with a capital letter. There may be
further capital letters in the word. • If the –b flag is set, count the number of
words that are hyphenated. This hyphen should not be at the start or end of a
word. • If the –c flag is set, count the number of words that start and end on
the same character. • If the –d flag is set, count the number of words that do
not start with a vowel. Note that these words can start with any character,
and do not just have to start with alphabetic characters. If no flags are
provided, it is assumed that all counts should be performed. It is suggested
that you remove all whitespace at the start and end of the document, as well
are removing all punctuation (.,?!:; and so on) – try doing this using a regular
expression. Assume that there is only 1 space between words. Remember
that to set command line arguments in Qt Creator, click on Projects in the left
menu, click on the Run menu and enter the arguments in the Command line
arguments field. You can also click the Run in terminal check box.
Downloaded by Polar magnats () lOMoARcPSD| COS3711/Assignment 1/2025 3
See the screenshot below for an example of the output for the arguments
that were used above.

C++ console application that implements the requirements of your assignment
step-by-step, with support for multiple files and flags using regular expressions.

✅ Features Implemented: Parses flags (-a, -b, -c, -d)

Supports multiple files

Applies regex to:

, Remove punctuation

Split text into words

Counts according to:

-a: Words >4 letters starting with a capital

-b: Hyphenated words (not starting or ending with -)

-c: Words that start and end with the same letter

-d: Words that do not start with a vowel

If no flags provided → all checks performed

If no arguments → usage instructions

📌 Full Code (C++): cpp Copy Edit #include #include #include #include #include
#include

using namespace std;

// Helper function to read file content into a string string readFile(const string&
filename) { ifstream file(filename); if (!file) { cerr << "Error opening file: " <<
filename << endl; return ""; } return string((istreambuf_iterator(file)),
istreambuf_iterator()); }

// Function to clean punctuation using regex string cleanText(const string& text)
{ // Remove punctuation and trim whitespace string cleaned = regex_replace(text,
regex(R"([.,?!:;])"), ""); cleaned = regex_replace(cleaned, regex(R"(^\s+|\s+$)"), "");
return cleaned; }

// Function to split text into words (assumes one space between words) vector
splitWords(const string& text) { vector words; regex wordRegex(R"(\s+)");
sregex_token_iterator it(text.begin(), text.end(), wordRegex, -1);
sregex_token_iterator end; for (; it != end; ++it) { if (!it->str().empty())
words.push_back(it->str()); } return words; }

// Count functions bool isCapitalLongWord(const string& word) { return
word.length() > 4 && isupper(word[0]); }

bool isHyphenatedWord(const string& word) { return word.find('-') != string::npos
&& word[0] != '-' && word.back() != '-'; }
2,37 €
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
En ligne et en PDF
Tu n'es attaché à rien

Faites connaissance avec le vendeur

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
ivymwendwa47820 University of South Africa (Unisa)
S'abonner Vous devez être connecté afin de pouvoir suivre les étudiants ou les formations
Vendu
357
Membre depuis
1 année
Nombre de followers
156
Documents
883
Dernière vente
1 mois de cela

3,6

71 revues

5
29
4
13
3
13
2
5
1
11

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions