Question
C++ Need help modifying the C++ program bellow to Create two functions, one to calculate the average of the scores,the second function will create graph
C++
Need help modifying the C++ program bellow toCreate two functions, one to calculate the average of the scores,the second function will create graph for the counter and the average score. Usethe file studentscores.txt (located at thebottom of the page).Create graphs for the counter and average values calculated.Show: the output, Graph, Scores and scoresout.txt
#include
// Create two functions, one to calculate the average of the scores // the second function will create graph for the counter and the average score. // You will need the file studentscores.txt // Create graphs for the counter and average values calculated
int main( ) { string firstName, lastName; int score = 0, total = 0 , counter = 0; double average = 0.0; ifstream f1 ("studentscores.txt", ios::in); ofstream f2 ("scoresout.txt",ios::out); //inputStream.open("studentscores.txt"); //inputStream >> score; //inputStream >> firstName >> score; while ( f1>>firstName>>score, !f1.eof() ) { cout << "Name: " << firstName << " " << endl; cout << "Score: " << score << endl; // enter graph f2 << "Name: " << firstName << " " << endl; f2 << "Score: "<< score << endl; counter++; total = total + score; //inputStream >> firstName >> score; } //INSERT BELOW acall to the average function
// graph twice, first to graph the counter and second to graph the average values
// print the graphs only to the screen f2 << " number of students = "<< counter<< endl; f2 << " total of the scores = "<< total<< endl; f2 << " the average score = " << average << endl; // graph counter and average values f1.close(); f2.close();
return 0; }
studentscores.txt
Anna 90 Thomas 75 Gabe 100 Nick 78 Eva 100 Joe 80 Maggie 9
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started