1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
likoan [24]
3 years ago
14

Create a function named PrintStudents, which takes a string input filename and an integer minimum score value and a string outpu

t file name as a parameters. The function will read the student scores and names from the file and output the names of the students with scores greater than or equal to the value given. This function returns the integer number of entries read from the file. If the input file cannot be opened, return -1 and do not print anything to the file.Read each line from the given filename, parse the data, process the data, and write the required information to the file.Each line of the file contains , , . Read and parse the data, then write to the output file the names and classes for scores matching the criteria.Example: With the following data and value of 80:Constance Shelton, 67, APPM 2002Charlotte Edwards, 85, CSCI 1300Alyssa Hill, 78, MATH 1000Pat Owens, 75, HUMN 1342Shannon Jimenez, 96, LING 2000Kristen Swanson, 80, PSYC 1001Jim Schwartz, 60, CVEN 3241Your function should return 7 and output to the file should contain:Charlotte Edwards, CSCI 1300Shannon Jimenez, LING 200Kristen Swanson, PSYC 1001You only need to write the function code. Our code will create and test your class.HINT: We have provided a function that may make the parsing easier:int split(string s, char sep, string words[], int max_words);
Computers and Technology
1 answer:
givi [52]3 years ago
4 0

Answer:

The code is implemented below on C++

Explanation:

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

// function declaration

int PrintStudents(string inputFile, int min_score,string outputFile);

int split(string s,char sep, string words[], int max_words );

int main() {

// test the function

              int n = PrintStudents("students.txt",80,"outStudents.txt");

              if(n != -1)

                             cout<<"\n No. of students : "<<n<<endl;

              else

                             cout<<"\n No such file exists";

              return 0;

}

// function to write the details of the students whose score >= min_score

// inputs : input file, minimum score and output file

// output : number of records read, -1 if error

int PrintStudents(string inputFile, int min_score,string outputFile)

{              // open the input file

              ifstream fin(inputFile.c_str());

              // if input file can be opened

              if(fin.is_open())

              {              // open the output file for writing

                             ofstream fout(outputFile.c_str());

                             int n=0,score;

                             string line;

                             string words[3];

                             // read till the end of file

                             while(!fin.eof())

                             {

                                            getline(fin,line);

                                            n++;

                                            // get the score from the record read

                                            score = split(line,',',words,3);

                                            // check if score>=min_score, then write to output file

                                            if(score >= min_score)

                                                           fout<<words[0]<<", "<<words[2]<<"\n";

                                            if(fin.eof())

                                                           break;

                             }

                             // close the files

                             fin.close();

                             fout.close();

                             return n; // return the number of records read

              }else

              {

                             fin.close();

                             return -1; // file not found

              }

}

// function to split a string on a given separator and return the score

// inputs : string , word separator, array of words and max_words

// output is the score

int split(string s,char sep, string words[], int max_words )

{

              int index=0,i=0 ;

              //loop to extract the words from the line

              while(s.find(sep,index+1)!= -1){

                             words[i] = s.substr(index,s.find(sep,index+1)-index);

                             i++;

                             index = s.find(sep,index+1)+2;

              }

              words[i] = s.substr(index); // extract the last word

              // convert to integer and return the score

              return(stoi(words[1]));

}

You might be interested in
Based on your understanding of Moore’s Law, what do you predict will be the next trend in the evolution of computers?
miss Akunina [59]

Actually, the answer is (B) Computers will continue to become smaller in size and become faster.  For example, google  i9-9900k mini itx pc build. You can have an insanely powerful pc and it be very small.

5 0
3 years ago
How does ludonarrative apply to game design
Amiraneli [1.4K]

When gaming and story work together to produce a meaningful and engaging experience, this is referred to as Ludonarrative harmony. From the standpoint of design implementation, it is the synchronized interactions between in-game activities (mechanics) and in-world context.

<h3>What is game design?</h3>

Game design is a broad area that includes computer science/programming, creative writing, and graphic design.

It is also defined as the use of design and aesthetics to the creation of a game for pleasure, educational, exercise, or experimental objectives

Learn more about game design:
brainly.com/question/26066869
#SPJ1

6 0
2 years ago
On her last performance review, beverly's boss commented that she needs to help out her co-workers when they are busy in order t
labwork [276]
Inter personal. As she needs to work with persons, them being her co workers
4 0
4 years ago
Read 2 more answers
I need help picture above
m_a_m_a [10]

Answer:

The 2nd one on top and The Star ones.. (sorry if its wrong

Explanation:

7 0
3 years ago
Read 2 more answers
What is ‘Software Quality Assurance’?
Aleonysh [2.5K]

Answer: Software quality assurance is considered as the means under which one monitors the software processes and techniques used in order to ensure quality. The techniques using which this is attained are varied, and thus may also include ensuring accordance to more than one standards. It is referred to as a set of techniques that ensures the quality of projects in software process. These mostly include standards that administrators use in order to review and also audit software activities, i,e, these software meet standards.

5 0
3 years ago
Other questions:
  • The superintendent forbade the students to bring their books and copies in the exam hall. (into direct speech)​
    10·1 answer
  • To create a default value for a parameter in the parameter list of a function, you code a/an ________________ sign after the par
    5·1 answer
  • Approximately what percentage of the world population owns a smartphone?
    9·1 answer
  • Who is involved in helping shape the emotional impact of a film? (Select all that apply.)
    8·2 answers
  • Which line of code will print I like to code on the screen? print("I like to code") print(I like to code) print("I LIKE TO CODE"
    5·2 answers
  • Select the instances in which you should include a comma.
    13·1 answer
  • Dell Computers is a nationally recognized manufacturer of computers for the small business and home markets. If Dell were to ord
    9·1 answer
  • Ye lust, and have not: ye kill, and desire to have, and cannot obtain: ye fight and war, yet ye have not, because ye ask not.​
    15·1 answer
  • Name any three areas of of application of excel.
    12·1 answer
  • Which of these countries has very strict cultural
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!