Using Problem Solving with C++ (9th Edition) Chapter 2 to chapter 8 Can anyone h
ID: 3860434 • Letter: U
Question
Using Problem Solving with C++ (9th Edition) Chapter 2 to chapter 8
Can anyone help me to solve this problem?
Problem 1-
1.You will read grades from a file called gradebook.txt
2.The number of grade may vary – They are not always 10
3.You will read everything using String then convert grades to int
4.Create two two-dimensional arrays one for first name, last name and one for grades.
5.Count to see how many grades you have.
6.Create two more arrays one for average for each student and one for average for each test.
7.Create three SVG files to display
a.Average of each student
b.Average of each test
c.Sorted test average of course
8.Each bar should be different color preferably green for the highest and red for the lowest with decreeing green and increasing red as we go from highest to lowest.
9.You should be able to demonstrate your project and answer every question about your project.
10. Everything has to be in functions with proper documentation – Check chapter two for proper documentation.
Explanation / Answer
}
#include<iostream> #include<fstream> #include<string> #include<iomanip> using namespace chegg; // GetDatafrom to read and store data into two arrays, void GetDatafrom(ifstream& infile,string name[],int scores[][5],int& n) { n = 0; int i=0; int j=0; while(!infile.eof()) { infile >> name[i]; for(int j=0; j<5; j++) infile >> scores[i][j]; i++; } n = i; } char SetGrade(double avg) {
\ Here you can set Grade } // used to calculate the average test score and grade, void AverageOf(int a[][5],char grade[],double avg[],int no_of_students) { for(int i=0; i<no_of_students; i++) { double sum =0; for(int j=0; j<5; j++) sum+= a[i][j]; avg[i] = sum/static_cast<double> (5); grade[i] = SetGrade(avg[i]); } } // Result Print void Result(string name[],double avg[],int scores[][5],char grade[],int n) { for(int i=0; i<n; i++){ cout << left << setw(10)<< name[i]; for(int k=0; k<5; k++) cout << right << setw(8) << scores[i][k]; cout << endl; } cout << setw(8) <<"Averages "; for(int i=0; i<n; i++) cout << setw(5) << avg[i]; cout << endl; } int main() { string name[MAX]; int scores[MAX][5]; char grade[MAX]; int no_of_students; double avg[MAX]; ifstream infile("gradebook.txt"); if(!infile) { cout <<"file not found" << endl; return 0; } GetDatafrom(infile, name, scores, no_of_students); infile.close(); Averages(scores, grade, avg, no_of_students); Results(name,avg,scores,grade,no_of_students); return 0; }
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.