Create a program that determines grades at the end of the semester. So I current
ID: 3759266 • Letter: C
Question
Create a program that determines grades at the end of the semester.
So I currently need help with creating a program that determines the grades, and I'm not really sure where to start in terms of programming it, mostly I'm confused with how to properly set up vectors and multidimensional arrays to get my desired result. So far this is what I have set up with my code. If anybody has suggestions please help. Thanks.
NOTE: C++ CODE ONLY
Header File
---------------------------------
#ifndef GRADES_H
#define GRADES_H
class Grades
{
public:
Grades();
private:
};
#endif // GRADES_H
Grades.cpp
-------------------------
#include "grades.h"
Grades::Grades()
{
}
Int main
-------------
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int Grades[5][7] = {1,85,88,90,81,
2,73,68,75,77,
3,94,89,82,91,
4,88,79,81,84,
5, 71,65,78,73};
for(int i = 0; i < 5; i++)
{
cout << endl;
for(int j = 0; j < 7; j++)
{
cout << Grades[i][j];
}
cout << endl;
}
return 0;
}
I'm looking for help with this program since I'm not sure how to set up my three sections of code. I listed the specifications below if anybody needs more details.
Specifications
Construct a 5 x 7 two-dimensional array based on the following table
Calculate the average for each student and store it in the Ave column.
Calculate the weighted average for each student(the first grade gets a weight of .2, the second a weight of .3, the third a weight of .3, and the fourth a weight of .2) and store it in the Wt Ave column.
Output the contents of the entire array neatly formatted in columns and rows with appropriate row and column labels.
Student Grade 1 Grade 2 Grade 3 Grade 4 Ave Wt Ave 1 85 88 90 81 2 73 68 75 77 3 94 89 82 91 4 88 79 81 84 5 71 65 78 73Explanation / Answer
#include <iostream>
#include <fstream>
#include<iomanip>
//#include<ctime>
#include <cstdlib>
#include<string>
#include<stdlib.h>
//#include<cmath>
using namespace std;
int main()
{
const int NUMROWS =5;
const int NUMCOLS =7;
int i,j;
//int array [NUMROWS][NUMCOLS]={85,88,90,81,73,68,75,77,94,89,82,91,88,79,81,84,71,65,78,73};
int array [NUMROWS][NUMCOLS];
cout << " The Grades Text File Populated" <<endl;
cout <<"---------------------------- ";
string filename = "grades.txt";
string line;
ifstream inFile;
ofstream offFile;
inFile.open("grades.txt");
while ( getline(inFile,line))
{
cout<<line<<endl;
}
inFile.close();
cout << " New Grades Array" <<endl;
cout <<"---------------------------- ";
inFile.open("grades.txt");
offFile.open("temp.txt");
/* int index = 0;
while (! inFile.eof() )
{
getline (inFile,line);
array[index++];
}*/
for ( i = 0; i < 5; i++)
{
cout <<endl;
// array [i][0]=i+1;
for ( j = 0; j < NUMCOLS; j++)
{
//array [i][5]=0;
// array [i][6]=0;
offFile<<array[i][j]<< " ";
cout<<line<<endl;
}
}
inFile.close();
system ("pause");
//cout << " Save The New Array" <<endl;
//cout <<"---------------------------- ";
//inFile.open("grades.txt");
//offFile.open("temp.txt");
//inFile.close();
//offFile.close();
////remove("grades.txt");
//rename("temp.txt","grade.txt");
//system ("pause");
//return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.