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
balandron [24]
3 years ago
10

Write a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file

that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20.
The program performs the following tasks:
Read the file name of the tsv file from the user.
Open the tsv file and read the student information.
Compute the average exam score of each student.
Assign a letter grade to each student based on the average exam score in the following scale:
A: 90 = < X o
B: 80 = < x < 90
C: 70 = < X < 80
D: 60 = < x < 70
E: X < 60
• Compute the average of each exam.
• Output the last names, first names, exam scores, and letter grades of the students into a text file named report.txt. Output one student per row and separate the values with a tab character.
• Output the average of each exam, with two digits after the decimal point, at the end of report.txt. Hint: Use the setprecision manipulator to format the output.
Ex: If the input of the program is:
StudentInfo.tsv
and the contents of StudentInfo.tsv are: 70 45 59
Barrett Edan 96 97 88
Bradshaw Reagan 73 94 80
Charlton Caius 88 61 36
Mayo Tyrese 90 86 45
the file report txt should contain
Barrett Edan 70 45 59 F
Baadha Boagan 9e 157 89 A
Charlton Caius 73 94 80 B
Mayo and Tyrese 58 61 36 D
Stern and Brenda 90 36 45 C
Average midterm 83.40, midterm2 76.60, final 61.60
Computers and Technology
1 answer:
netineya [11]3 years ago
6 0
#include
#include
#include
#include
#include
#include


using namespace std;

// Class student required to store the data
class Student{
public:
string lname;
string fname;
int marks[3];
char grade;

// Function which generates the grade for student
void calculate_grade(){
double sum = 0;
for(int i=0;i<3;i++){
sum+= marks[i];
}
double average = sum/3;
if(average>=90 && average<100)
this->grade = 'A';
else if(average>=80)
this->grade = 'B';
else if(average>=70)
this->grade = 'C';
else if(average>=60)
this->grade= 'D';
else this->grade = 'F';
}
};

// This function reads the file , and creates a vector of Students data
vector read_file(string fileName){

// Opening the file
fstream fin;
fin.open(fileName);


// Temp variables
vector list;
vector row ;
string line, word, temp;

// Read the data into vector
while(getline(fin,line)){
row.clear();
stringstream s(line);

while(getline(s,word,'\t')){

row.push_back(word);

}
Student st;
st.fname = row[0];
st.lname = row[1];
st.marks[0] = stoi(row[2]);
st.marks[1] = stoi(row[3]);
st.marks[2] = stoi(row[4]);
st.calculate_grade();
list.push_back(st);
}
fin.close();
return list;
}

// This function takes filname to be output as input, and list of student
void writeFile(string filename, vector list){

// Opening the new file
ofstream fin(filename);
for(int i=0;i string line = list[i].fname+"\t"+list[i].lname+"\t"+to_string(list[i].marks[0])+"\t"
+to_string(list[i].marks[1])+"\t"+to_string(list[i].marks[2])+"\t"+list[i].grade+"\n";
fin<
}


// Find the stats required
double average1 =0,average2 =0 ,average3 = 0;
for(int i=0;i average1+=list[i].marks[0];
average2+=list[i].marks[1];
average3+=list[i].marks[2];
}
average1/=list.size();
average2/=list.size();
average3/=list.size();

// Writting the stats
fin<<"\n"<<"Average: "<<"mid_term1 "<
// Closing the file
fin.close();
}
int main(){

// Taking the input
cout<<"Enter the filename: ";
string filename;
cin>>filename;
vector list;

// Reading and Writting to the file
list = read_file(filename);
writeFile("report.txt",list);


}
You might be interested in
Choose the correct climate association for: deciduous forest
kow [346]

Answer:

Mid Latitude Climate!

Explanation:

I've studied this! Hope this helps! :)

3 0
3 years ago
Identify the true statements about the approach to privacy around the world. a. Uncertainty concerning the nature, extent, and v
Thepotemich [5.8K]

Answer:

a. Uncertainty concerning the nature, extent, and value of privacy is widespread.

d. Significant disagreement about privacy exists within the United States.

6 0
3 years ago
Write the necessary preprocessor directive to enable the use of the stream manipulators like setw and setprecision Additional No
Ksenya-84 [330]

We would use  #include<iomainp> header file accordingly.

<h3>What is manipulator?</h3>

Helping functions known as manipulators can change the input/output stream. It simply affects the I/O stream using the insertion () and extraction (>>) operators, not the value of a variable.

Special functions known as manipulators can be used in an I/O statement to change a stream's format specifications.

Operators who format the data presentation are known as manipulators.The application should contain the file iomanip.h to access manipulators.The manipulators endl, ws, ends, and flush are those without arguments.

Setw (val), Setfill (c), Setprecision (val), Setbase (val), SetIOS Flags (flag), and ResetIOS Flags are examples of manipulators with arguments (m).

Two categories of manipulators are typically in use: Specified and Unspecified.

To know more about pre-processor, visit:-

brainly.com/question/13100703

#SPJ4

4 0
2 years ago
What is an online alternative to customers sending checks via mail?
irinina [24]
Two service will notification in your email is Western Union and Money Gram
5 0
3 years ago
A step commonly used for Internet vulnerability assessment includes __________, which occurs when the penetration test engine is
lakkis [162]

Complete Question:

A step commonly used for Internet vulnerability assessment includes __________, which occurs when the penetration test engine is unleashed at the scheduled time using the planned target list and test selection.

Group of answer choices

A. scanning

B. subrogation

C. delegation

D. targeting

Answer:

A. Scanning.

Explanation:

A step commonly used for Internet vulnerability assessment includes scanning, which occurs when the penetration test engine is unleashed at the scheduled time using the planned target list and test selection.

Internet vulnerability assessment can be defined as the process of defining, analyzing, measuring, identifying, classification and prioritization of vulnerabilities in network resources used to access the internet. The main purpose of an internet vulnerability assessment is to provide necessary informations or data about the threats being posed to an individual or organization through the use of a scanning program or system such as a network security scanner

7 0
3 years ago
Other questions:
  • Which expansion slot is used by an NVMe compliant device?
    9·1 answer
  • A computer that no longer works after having minor repair work done to it may have been damaged by ____
    13·2 answers
  • Which command group does a user need to access the Formula dialog box?
    11·1 answer
  • What is "social
    13·2 answers
  • Create a script that will find the sum of the all multiples of 3 between 1 and 1000 by using For Loop. (Pseudo Code required) 3.
    7·1 answer
  • In the RSA system, the receiver does as follows:1. Randomly select two large prime numbers p and q, which always must bekept sec
    6·1 answer
  • Does nature behave the exact same way as fractals?
    15·1 answer
  • Asking for certain data twice is
    6·2 answers
  • In a typical day, what types of Computer-Mediated Communication do you use?
    8·1 answer
  • Which network protocol is used to handle the reliable delivery of information?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!