Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include <math.h>
- #include <set>
- #include <map>
- #include <queue>
- #include <deque>
- #include <fstream>
- #include <iomanip>
- #include <windows.h>
- typedef long long ll;
- using namespace std;
- void findCount(ifstream &read,string s) {
- read.open(s);
- vector<char> Grade;
- string temp;
- cout << setprecision(2) << showpoint << fixed;
- while (getline(read, temp)) {
- int Grade_finder = temp.size();
- Grade.push_back(temp[Grade_finder - 1]);
- }
- sort(Grade.begin(), Grade.end());
- float counter = 0, total = Grade.size() - 1;
- for (int i = 0; i < total; i++) {
- if (Grade[i] == Grade[i + 1]) {
- counter++;
- }
- else {
- counter++;
- float average = (counter / total) * 100;
- cout << "Number of student with the grade: " << Grade[i] << " is " << (int)counter << endl;
- cout << "The percentage of the student with grade " << Grade[i] << " is " << (int)average << "% \n";
- counter = 0;
- }//corner case
- if ((i + 1) == total) {
- counter++;
- cout << "Total abscent students are: " << (int)counter << endl;
- break;
- }
- }
- cout << "Total student attended: " << Grade.size()<<"\n";
- read.close();
- }
- int main() {
- ifstream read,math,checker;
- string s;
- cout << "INTRODUCTION TO PROGRAMMING GRADES \n";
- s = "Grades.txt";
- findCount(read,s);
- cout << "MATHEMATICS FOR COMPUTER SCIENTIST GRADES \n";
- s = "MathGrade.txt";
- findCount(math,s);
- s = "Checker.txt";
- tellgdetector(checker,s);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement