#include #include #include #include using namespace std; struct marks { string id; double quiz[2], ass[2], labTest[2]; double test, proj, final, total; char grade; }; struct marks s_marks[50]; void studentGrade(int i) { s_marks[i].total = ((s_marks[i].quiz[0] + s_marks[i].quiz[1]) * 0.05) + ((s_marks[i].ass[0] + s_marks[i].ass[1]) * 0.15) + ((s_marks[i].labTest[0] + s_marks[i].labTest[1]) * .20) + (s_marks[i].test * 0.15) + (s_marks[i].proj * 0.15) + (s_marks[i].final * 0.30); if (s_marks[i].total >= 90 && s_marks[i].total <= 100) s_marks[i].grade = 'A'; else if (s_marks[i].total >= 80 && s_marks[i].total <= 90) s_marks[i].grade = 'B'; else if (s_marks[i].total >= 60 && s_marks[i].total <= 80) s_marks[i].grade = 'C'; else if (s_marks[i].total >= 40 && s_marks[i].total <= 60) s_marks[i].grade = 'D'; else s_marks[i].grade = 'F'; } int gradeA = 0, gradeB = 0, gradeC = 0, gradeD = 0, gradeF = 0; void countGrade(int i) { if (s_marks[i].grade == 'A') gradeA++; else if (s_marks[i].grade == 'B') gradeB++; else if (s_marks[i].grade == 'C') gradeC++; else if (s_marks[i].grade == 'D') gradeD++; else if (s_marks[i].grade == 'F') gradeF++; } int no_of_students; void outputResult() { cout << "****************"; cout << setw(85) << "RESULT FOR BITP1113" << endl; cout << "****************"; cout << endl; cout << setw(15) << "Matrix Num" << setw(15) << "Quiz(5%)" << setw(15) << "Ass(15%)" << setw(15) << "labTests(20%)" << setw(15) << "Project(5%)" << setw(15) << "Mid-Term(15%)" << setw(15) << "Final(30%)" << setw(15) << "Total(100%)" << setw(15) << "Grade"; cout << endl; cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl; for (int i = 0; i < no_of_students; i++) { cout << setw(15) << s_marks[i].id << setw(15) << ((s_marks[i].quiz[0] + s_marks[i].quiz[1]) * 0.05) << setw(15) << ((s_marks[i].ass[0] + s_marks[i].ass[1]) * 0.15) << setw(15) << ((s_marks[i].labTest[0] + s_marks[i].labTest[1]) * .20) << setw(15) << (s_marks[i].proj * 0.15) << setw(15) << (s_marks[i].test * 0.15) << setw(15) << (s_marks[i].final * 0.30) << setw(15) << s_marks[i].total << setw(15) << s_marks[i].grade; cout << endl; } cout << "\n\n"; cout << "Statistics" << endl; cout << "------------------------------------" << endl; cout << "Total Students for Grade A: " << gradeA << endl; cout << "Total Students for Grade B: " << gradeB << endl; cout << "Total Students for Grade C: " << gradeC << endl; cout << "Total Students for Grade D: " << gradeD << endl; cout << "Total Students for Grade F: " << gradeF << endl; cout << "\n\n"; cout << "Graph" << endl; cout << "------------------------------------" << endl; cout << "A: "; for (int i = 0; i < gradeA; i++) { cout << "*"; } cout << endl; cout << "B: "; for (int i = 0; i < gradeB; i++) { cout << "*"; } cout << endl; cout << "C: "; for (int i = 0; i < gradeC; i++) { cout << "*"; } cout << endl; cout << "D: "; for (int i = 0; i < gradeD; i++) { cout << "*"; } cout << endl; cout << "F: "; for (int i = 0; i < gradeF; i++) { cout << "*"; } cout << endl; } int main() { int i = 0; ifstream fin; fin.open("students_grade.txt", ios::in); if (!fin) { cout << "File not found."; } else { while (1) { fin >> s_marks[i].id; fin >> s_marks[i].quiz[0]; fin >> s_marks[i].quiz[1]; fin >> s_marks[i].ass[0]; fin >> s_marks[i].ass[1]; fin >> s_marks[i].labTest[0]; fin >> s_marks[i].labTest[1]; fin >> s_marks[i].test; fin >> s_marks[i].proj; fin >> s_marks[i].final; studentGrade(i); countGrade(i); i++; if (fin.eof()) break; } } no_of_students = i; outputResult(); fin.close(); return 0; }
please provide me flow chart for the foolowing code
please do not copy and paste from another place as answer will dislike
#include<iostream>
#include<fstream>
#include<string.h>
#include<iomanip>
using namespace std;
struct marks {
string id;
double quiz[2], ass[2], labTest[2];
double test, proj, final, total;
char grade;
};
struct marks s_marks[50];
void studentGrade(int i) {
s_marks[i].total = ((s_marks[i].quiz[0] + s_marks[i].quiz[1]) * 0.05) + ((s_marks[i].ass[0] + s_marks[i].ass[1]) * 0.15) + ((s_marks[i].labTest[0] + s_marks[i].labTest[1]) * .20) + (s_marks[i].test * 0.15) + (s_marks[i].proj * 0.15) + (s_marks[i].final * 0.30);
if (s_marks[i].total >= 90 && s_marks[i].total <= 100) s_marks[i].grade = 'A';
else if (s_marks[i].total >= 80 && s_marks[i].total <= 90) s_marks[i].grade = 'B';
else if (s_marks[i].total >= 60 && s_marks[i].total <= 80) s_marks[i].grade = 'C';
else if (s_marks[i].total >= 40 && s_marks[i].total <= 60) s_marks[i].grade = 'D';
else s_marks[i].grade = 'F';
}
int gradeA = 0, gradeB = 0, gradeC = 0, gradeD = 0, gradeF = 0;
void countGrade(int i) {
if (s_marks[i].grade == 'A') gradeA++;
else if (s_marks[i].grade == 'B') gradeB++;
else if (s_marks[i].grade == 'C') gradeC++;
else if (s_marks[i].grade == 'D') gradeD++;
else if (s_marks[i].grade == 'F') gradeF++;
}
int no_of_students;
void outputResult() {
cout << "****************";
cout << setw(85) << "RESULT FOR BITP1113" << endl;
cout << "****************";
cout << endl;
cout << setw(15) << "Matrix Num" << setw(15) << "Quiz(5%)" << setw(15) << "Ass(15%)" << setw(15) << "labTests(20%)" << setw(15) << "Project(5%)" << setw(15) << "Mid-Term(15%)" << setw(15) << "Final(30%)" << setw(15) << "Total(100%)" << setw(15) << "Grade";
cout << endl;
cout << "----------------------------------------------------------------------------------------------------------------------------------------" << endl;
for (int i = 0; i < no_of_students; i++) {
cout << setw(15) << s_marks[i].id << setw(15) << ((s_marks[i].quiz[0] + s_marks[i].quiz[1]) * 0.05) << setw(15) << ((s_marks[i].ass[0] + s_marks[i].ass[1]) * 0.15) << setw(15) << ((s_marks[i].labTest[0] + s_marks[i].labTest[1]) * .20) << setw(15) << (s_marks[i].proj * 0.15) << setw(15) << (s_marks[i].test * 0.15) << setw(15) << (s_marks[i].final * 0.30) << setw(15) << s_marks[i].total << setw(15) << s_marks[i].grade;
cout << endl;
}
cout << "\n\n";
cout << "Statistics" << endl;
cout << "------------------------------------" << endl;
cout << "Total Students for Grade A: " << gradeA << endl;
cout << "Total Students for Grade B: " << gradeB << endl;
cout << "Total Students for Grade C: " << gradeC << endl;
cout << "Total Students for Grade D: " << gradeD << endl;
cout << "Total Students for Grade F: " << gradeF << endl;
cout << "\n\n";
cout << "Graph" << endl;
cout << "------------------------------------" << endl;
cout << "A: "; for (int i = 0; i < gradeA; i++) { cout << "*"; } cout << endl;
cout << "B: "; for (int i = 0; i < gradeB; i++) { cout << "*"; } cout << endl;
cout << "C: "; for (int i = 0; i < gradeC; i++) { cout << "*"; } cout << endl;
cout << "D: "; for (int i = 0; i < gradeD; i++) { cout << "*"; } cout << endl;
cout << "F: "; for (int i = 0; i < gradeF; i++) { cout << "*"; } cout << endl;
}
int main() {
int i = 0;
ifstream fin;
fin.open("students_grade.txt", ios::in);
if (!fin) {
cout << "File not found.";
}
else {
while (1) {
fin >> s_marks[i].id;
fin >> s_marks[i].quiz[0];
fin >> s_marks[i].quiz[1];
fin >> s_marks[i].ass[0];
fin >> s_marks[i].ass[1];
fin >> s_marks[i].labTest[0];
fin >> s_marks[i].labTest[1];
fin >> s_marks[i].test;
fin >> s_marks[i].proj;
fin >> s_marks[i].final;
studentGrade(i);
countGrade(i);
i++;
if (fin.eof()) break;
}
}
no_of_students = i;
outputResult();
fin.close();
return 0;
}
Step by step
Solved in 3 steps with 5 images