So I seem to be confused on how to populate an array (2D and an array on the heap) here is what I am suppose to do:
Create a Static 2D Array on the Stack to hold a set of four test scores for five students.
Create dynamic parallel arrays (on the heap) to hold student names, student id, average score, and a letter grade based on standard grade scale.
Populate the arrays from the file Student Data.txt
Write a program to do the following tasks:
1. Calculate average score for each student.
2. Assign letter grade for each student.
3. Display name, id, scores, average, and grade for each student.
4. calculate the class average score and display.
I know I have not yet done 1-4 in my code but I need help on how I would populate the arrays. Any help would be great! thanks!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
// main.cpp
// Program 8
// Created by William Blake Harp on 7/16/14.
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <vector>
int size;
int sum_of_test_scores;
double average;
double class_average;
using namespace std;
int main()
{
ifstream inputFile;
string data = "Student Data.txt";
//2D Array.
const int students = 5;
const int test_scores = 4;
int s[students][test_scores];
//Arrays on the heap.
int* arrayNames = nullptr;
arrayNames = new int[size];
int* arrayID = nullptr;
arrayID = new int[size];
int* arrayAverage = nullptr;
arrayAverage = new int[size];
int* arrayLetterGrade = nullptr;
arrayLetterGrade = new int[size];
// Open the file
inputFile.open("data.c_str");
// Populating 2D array test_scores.
for ((int i = 2; i != test_scores; i % 2) == 0)
{
cout << inputFile << endl;
}
// Populating array "arrayNames"
for ((int i = 0; i != arrayNames; i % 2) == 0)
{
cout << inputFile << endl;
}
// Populating array "arrayID"
for ((int i = 1; i != arrayID; i % 2) == 0)
{
cout << inputFile << endl;
}
// Close the file.
inputFile.close();
return 0;
}// End Code.
|