Please assist with creating a program using arrays and functions for student grades. These are the requirements:
To create and execute a C++ program with functions and arrays that will read student information input from an input text file, calculate the test average, program average, course average, and the letter grade earned and output the result to the monitor as well as to an output text file. Program must allow grades to be calculated for unknown but finite number of students’ records in the input text file. For this assignment, the maximum number of students is limited to 40. The letter grade earned is based on the course average as noted below.
Course Average
Letter Grade
90 - 100
A
80 - 89
B
Below 80
F
The following is required:
- Your program must prompt the user for and read the input text file name/path.
- You are required to use one or more functions for each of the following:
- Output descriptive header.
- Read a student’s name and scores into two dimensional string and integer arrays ( string names[40][2] and int scores[40][6] ). Must use an outer while loop and two inner for loops.
- Calculate the total ( int total[40] and two for loops)
- Calculate the program average, test average, course averages, (float averages[40][3] and two for loops). You may also declare three 1D float arrays for the averages and use one or more functions.
- Calculate the letter grade (char grades[40] and one outer for loop)..
- Output student name, total points, program average, test average, and course average to a text file as well as the monitor. Must use an outer for loop.
Note: You must check for file input/output stream failure.
Program Input
The input must be read from a text file located on a disk. It must consist of the following information:
· Student’s First Name (alphabetic);
· Student’s Last Name (alphabetic);
· First Program Grade (a number between 0 and 100);
· Second Program Grade (a number between 0 and 100);
· Third Program Grade (a number between 0 and 100);
· First Test Grade (a number between 0 and 100);
· Second Test Grade (a number between 0 and 100);
· Third Test Grade (a number between 0 and 100);
this is what I have thus far which isn't running: :sad::sad::mad:
//Preprocessor Directives
#include<iostream>
#include<conio.h>
#include<iomanip>
#include<fstream>
using namespace std;
//Global constrants and global variables
void headerfn();
void inputfn(ifstream& inputFile,ofstream& outputFile,string names[],int scores[][],int count[]);
void totalfn(ifstream& inputFile, ofstream& outputFile,int total[]);
void averagesfn(ifstream& inputFile, ofstream& outputFile,float averages[][]);
void calculategradefn(char grade[]);
//Main function definition
void main()
{
headerfn();
//**************************************************************************************************
//block in main
//Declare and open/close files
fin.open("input.txt");
if(!fin)return;
ifstream fin;
ofstream fout;
char inputFile[51];
char outputFile[51];
cout<<"Welcome to the IT210 Grade Calculator"<<endl;
cout<<"Please enter the name/path of input file <e.g.input4.txt>: ";
cin>>inputFile;
cout<<endl;
cout<<"Thank you! You entered";
cin>>fileName;
fin.open(inputFile);
if (!fin)
{
cout<<"Cannot open the input file."<<endl;
return 1;
}
cout<<"Enter the output file name: ";
cin>>outputFile;
cout<<endl;
fout.open(outputFile);
if (!fout)
{
cout<<"Cannot open the output file."<<endl;
return 1;
}
fin.close();
fout.close();
//************************************************************************************************
string names[40][2];
int scores[40][6];
int total[40];
float averages[40][3];
char grade[40];
int count;
ifstream inputFile;
ofstream outputFile;
//input fn block
void inputfn(string names[][],int scores[][], count);
count=0;
while (fin&&count<40)
{fin>>name[count][0]
>>name[count][1];
for (int col=0; col<6;col++)
{fin>>scores[count][col];}
if (fin.peek()=='\n')fin.ignore();
count++;
}//end of while
for (int row =0; row<count; row++)
{
total [row]=0;
for (int col=0; col<6; col++)
total[row]= total [row] + scores [row][col];
}//end of outer loop
for (int row=0; row<count; row++)
{cout<<setw(20)<<name[row][0]+' '+name[row][1];
for (int col=0; col<6;col++)
{cout<<setw(5)<<scores[row][col];}
cout<<setw(5)<<total[row];
cout<<endl;
}//end of outer for
cout<<"Pres any key to continue...";
getch();
}//end of main
//Function Definitions
}//end of headerfn
//definition of function calculateAverage
int calculateAverage(int number1, int number2, int number3)
{//start of function calculateAverage
int average;
average= number1+number2+number3/3;
return average;
}//end of function calculateAverage
//assign whether pass or fail
char assignGrade(int average)
{
if (average > 50) {
cout << "Pass:";
}
else if(average == average) {
cout << "Pass:";
}
else {
cout << "Fail:";
cout << "Fail:";
}
}