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
Genrish500 [490]
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= 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:
Barrett Edan 70 45 59
Bradshaw Reagan 96 97 88
Charlton Caius 73 94 80
Mayo Tyrese 88 61 36
Stern Brenda 90 86 45
the file report.txt should contain:
Barrett Edan 70 45 59 F
Bradshaw Reagan 96 97 88 A
Charlton Caius 73 94 80 B
Mayo Tyrese 88 61 36 D
Stern Brenda 90 86 45 C
Averages: midtermi 83.40, midterm2 76.60, final 61.60
Computers and Technology
1 answer:
kvasek [131]3 years ago
3 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
How dependent are we on technology? ​
rusak2 [61]

very independent  : ) we use it for everything

3 0
4 years ago
Read 2 more answers
Which of the following could be true of two diffrent speicies that have competitieve realtionship in the same ecosytem?
chubhunter [2.5K]

they both an enemy that is the same but they also have a same niche so the have the same niche

6 0
3 years ago
I need help Asap!!! So the question is "Compare and contrast Web page and Websites". ​
777dan777 [17]

Answer:

A website is a mix of web pages while a web page is a single entity.

Explanation:

4 0
3 years ago
What number system is the basis for all of the powerful computers and electronic devices in the world?
labwork [276]

Answer:

Binary

Explanation:

3 0
3 years ago
In the context of data quality management tools, _____ software is one that gathers statistics, analyzes existing data sources a
Dimas [21]

Answer:

Data-profiling software

Explanation:

Data-profiling software -

It refers to the software , that helps to collect the data or information from a particular existing source and performed it analysis , is referred to as a Data-profiling software .

The software helps to determine information about a topic , or analyse the pattern , for the process of comparison etc.

Hence , from the given information of the question ,

The correct answer is Data-profiling software .

5 0
3 years ago
Other questions:
  • Prompt the user to input an integer, a double, a character, and a string, storing each into separate variables. Then, output tho
    9·1 answer
  • The animation industry is solely reliant on 3-D modeling and 3-D virtualization to create the animated movies in the cinemas.
    9·2 answers
  • How do you screen shot and copy paste the screenshot from chrome book
    11·2 answers
  • Which attitudes are most common among successful IT professionals?
    7·1 answer
  • Which of the following is a strategy used to enhance communication in a presentation?
    14·1 answer
  • You have created a PivotChart showing sales by quarter by sales rep. Before presenting it to management, you notice thename of a
    7·1 answer
  • Discuss your favorite video games and why you like them. What types of features make a game fun to play? Why are they features e
    11·2 answers
  • Display all the lines in unixPasswd that contain at least 10 consecutive lowercase letters. How many names are there in total th
    12·1 answer
  • What will be the output of using the element in the given HTML code?
    6·1 answer
  • What security setting can cause a mobile device to erase installed apps and data if the passcode is incorrectly entered a number
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!