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

help C++ Write a program that uses functions to read and process the data from a

ID: 3734947 • Letter: H

Question

help C++

Write a program that uses functions to read and process the data from a formatted file. The program should contain the following exact functions: 1. A ReadConcepts function that reads a list of concepts/strings from the LIST.tit text file (one concept per line), stores them into an array of strings, and count how many concepts are in the list. The function should have two parameters (the array of concepts and a reference to the number of concepts in the array and should not return a value. Declare SIZE as a global constant (declared before all functions) initialized with a value large enough to hold all values from the file void ReadConcepts (string ArrayConcepts lSIZE), Int & Numberconcepts) 2. function that prompt the user to enter a letter from A to z ora to z, lets the user input An EnterLetter a character, validates it (check if it is a valid letter), and if it is not, repeats the input of the character until it is a valid letter and returns it. The function should not have any parameters and should return the letter char EnterLetter() 3. A PrintConcepts function that prints all the concepts from the array. The function should receive the array of concepts and the number of concepts as parameters and should not return any values. void Printconcepta (string Arrayconceptais148 ob:nces 4. A Printconceptswi thout Spaces function that prints ali the concepts from the array that do not contain spaces. The function should receive the array of concepts and the nomber of concepts as parameters and should not return any values. 5. A PrintConceptaLetr function that prints all the concepts from the árray that contain the letter (small or large caps).The function should receive the array of concepts and the number of concepts a Letter as parameters and should not return any vatues. function to read the concepts from the filé and store function to enter a em 6. A main function that calls the usersnsept in Arraycoacepts and determine the ucalls the from the user, and then calls the s (for the letter returned by in various for ithe and iables to print the concepts

Explanation / Answer

Please find the code below with detailed inline comments.

CODE

======================

#include <iostream>
#include <cstring>
#include <iomanip>
#include <fstream>

#define SIZE 512
using namespace std;

void ReadConcepts(string ArrayConcepts[SIZE], int& NumberConcepts){
ifstream inFile;
string str;
int i = 0;

inFile.open("LIST.txt");
if (!inFile) {
cout << "Unable to open file";
exit(1); // terminate with error
}

while (inFile >> str) {
NumberConcepts ++;
ArrayConcepts[i] = str;
i ++;
}

inFile.close();
}

char EnterLetter() {
char ch;
while(1) {
cout << "Enter a character(a-z, A-Z : ";
cin >> ch;
if((ch >= 'a' && ch <='z') || (ch >= 'A' && ch <='Z'))
break;
cout << "Invalid character,........try again!";
}
return ch;
}

void PrintConcepts(string ArrayConcepts[SIZE], int NumberConcepts) {
for(int i=0; i<NumberConcepts; i++) {
cout << ArrayConcepts[i] << endl;
}
}

void PrintConceptsWithoutSpaces(string ArrayConcepts[SIZE], int NumberConcepts) {
for(int i=0; i<NumberConcepts; i++) {
int containsSpace = 0;
for(int j=0; j<ArrayConcepts[i].length(); j++) {
if(ArrayConcepts[i][j] == ' ')
containsSpace = 1;
}

if(containsSpace == 0)
cout << ArrayConcepts[i] << endl;
}
}

void PrintConceptsLetter(char letter, string ArrayConcepts[SIZE], int NumberConcepts) {
for(int i=0; i<NumberConcepts; i++) {
int containsLetter = 0;
for(int j=0; j<ArrayConcepts[i].length(); j++) {
if(ArrayConcepts[i][j] == letter || ArrayConcepts[i][j] == char(tolower(letter)))
containsLetter = 1;
}

if(containsLetter == 0)
cout << ArrayConcepts[i] << endl;
}
}
int main() {
int NumberConcepts;
string ArrayConcepts[SIZE];
ReadConcepts(ArrayConcepts, NumberConcepts);
char ch = EnterLetter();

PrintConcepts(ArrayConcepts, NumberConcepts);
PrintConceptsWithoutSpaces(ArrayConcepts, NumberConcepts);
PrintConceptsLetter(ch, ArrayConcepts, NumberConcepts);
return 0;
}