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
Which component is most likely to allow physical and virtual machines to communicate with each other?
Diano4ka-milaya [45]

A component which is most likely to allow both physical and virtual machines to communicate with each other is a: virtual switch.

<h3>What is virtualization?</h3>

Virtualization can be defined as the creation of an abstract layer over computer hardware primarily through the use of a software, in order to enable the operating system (OS), storage device, server, etc., to be used by end users over the Internet.

In Cloud computing, some of the components (features) which is not required for a successful virtualization environment include the following:

  • Virtual machine
  • Host machine
  • Hypervisors

In conclusion, we can infer and logically deduce that a component which is most likely to allow both physical and virtual machines to communicate with each other is a virtual switch because it enables the virtual servers and the desktops to communicate.

Read more on virtualization here: brainly.com/question/14229248

#SPJ1

Complete Question:

Which component is most likely to allow physical and virtual machines to communicate with each other?

VHD.

Virtual switch.

Hyper V.

Host OS.

8 0
2 years ago
Brake fluid is made up of a chemical that:
TEA [102]

A) IS MOSTLY JUST ENGINE Oil.

7 0
3 years ago
Read 2 more answers
Which task can be completed with the Template Organizer?
spin [16.1K]

Answer:

B is the answer

Explanation:

i just got it right

8 0
3 years ago
Read 2 more answers
Effective nonverbal communication can cause tension.<br><br> True or False
agasfer [191]

Explanation:

When your nonverbal signals match up with the words you're saying, they increase trust, clarity, and rapport. When they don't, they can generate tension, mistrust, and confusion.

4 0
3 years ago
"love takes off masks we fear we cannot live without and cannot live within" what is the meaning to this quote?​
Bingel [31]

Answer: It's similiar to the quote "You bring out the best of me" When you're in love, you feel the need to be yourself and that you don't have to hide it.   Love brings out the real you.

Hope this helps.

Explanation:

7 0
3 years ago
Other questions:
  • Suppose you are using a Mac to read your e-mail messages, and you receive an
    8·2 answers
  • The act of engaging in crime through the use of a computer or similar type of device is called:
    8·1 answer
  • Explain in a few sentences the difference between analytical papers and argumentative papers.
    8·2 answers
  • Where in an email would u find information about the action requirements​
    9·1 answer
  • Write an assembly program that will prompt the user for 3 inputs (let’s abstractly call them a, b, and c) without a leading stri
    13·1 answer
  • Which of the following are the dimensions of feasibility? Group of answer choices cost, schedule, technical, and organizational
    14·1 answer
  • What is the function of a text box in Microsoft word?​
    13·1 answer
  • Assume that you have the business data in various sources such as Excel, .csv, text files and Access, Oracle databases. Write th
    9·1 answer
  • Find the total cost of a $125 coat purchased in Los Angeles County where the sales tax is 9%. Use the expression c + 0.09c
    10·1 answer
  • Looking for similarities between concepts or problems is referred to as
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!