Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

,Part 2: Programming Problem (15pts) Underneath the commented answers to the que

ID: 3568558 • Letter: #

Question

,Part 2: Programming Problem (15pts)
Underneath the commented answers to the questions in Part 1, write a working C++
program for the following task.
Assignment Grade Calculation: A certain class has no more than 100 students and has 6
Assignments each worth 20 points throughout the semester. Write a program that will read the
names and scores of the students from a file. The name of the first student will be on the first
line and their 6 scores separated by spaces on the next line (the two files your program will be
tested against are given on Blackboard). This will repeat for all students in the class. First ask
the user for the file name and open it for reading. Be sure that it opens properly. For every
student in the class read in the name of the student into an array and their scores on the 6
Assignments into a 2D array. It is possible to earn half a point grades (for example 18.5), somake the type of the array for the scores appropriate. The index of the name and row of the
grades should link the two arrays as parallel.
After the scores are read in, display a table that includes the student names, their scores on the
assignments and their average after dropping the lowest grade.

Explanation / Answer

C++ Program:

#include "stdafx.h"
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>

using namespace std;

int main(){

string name[100];
float avg[100],subAvg[6];
marks marks[100][6];
int i=0;
float sum,subSum = 0;
int row;

//File Input and Output
ifstream fin;
fin.open("input.txt");
if(!fin){
    cout<<"Input failure ";
    system ("Pause");
    return 1;
    }

while(fin)
{
  fin>>fname;
  col = 1;
  fin>>marks[row][0];
  min = marks[row][0];
  sum = marks[row][0];
  while(i<6)
  {
   fin >> marks[row][i];
   if(marks[row][col] < min)
    min = marks[row][col];
   sum += marks[row][col];
   col++;
  }
  sum -= min;
  avg[row] = sum / 5;
  row ++;
}

for(int j=0;j<row;j++)
{
  cout<<" "<<name;
  for(i=0;i<6;i++)
   cout<<" "<<marks[j][i];
  j++;
  cout<<" "<<avg[j];
  cout<<" ";
}
  fin.close();
   system("pause");
   return 0;
}