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

Lab Description: For this assignment, practice using multidimensional arrays It

ID: 3888709 • Letter: L

Question

Lab Description: For this assignment, practice using multidimensional arrays It will read CLA4.csv. CLA4.csV contains a table of students grades for several graded items (see the following) name gradeO/grade1 grade2 grade3 grade4Igrade5 grade6 grade 7Igrade8 grade9 student0/77/90/69/89/66/62|70/80/69/86 Format The items are all separated by a “". There are 10 grade items and 10 students Read Read the first line and skip the first column (name) and store the remaining column headers (grade(Ü) in a string array called gradeltems From the second line to the end, the format is the same. Store the first column (student(i)) in a string array called students. Store the remaining columns in a multidimensional array called scores Loops Get the sum and average of the scores for each of the gradeltems and each of the students. This will require that a nested loop for the sum and average the gradeltems and another nested loop for the sum and average of the students Output The output should be stored in a file called cla4Stats.csv. It is not required to be separated by a specified format. The gradeltems statistics information should be saved in the following order: grade(i) sum average The students statistics information should be saved in the following order student i)lsum laverage

Explanation / Answer

grades.txt

Grades1.cpp

#include<stdio.h>
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include <iomanip>
#include<fstream>
using namespace std;
void store(string);
void store2(int);
int p=0,q=0;
string grade_array[10];
int score_array[10];
int main()
{
char content[15][100];
int avg_array[100];
int avg=0,sum=0;
char *token,*token1;
int i=0,count=0,g=0,item=0,key=0,flag=0;
FILE *file = fopen( "Asc4.txt", "r" );
cout<<"The Content From File is: "<<endl;
cout<<"----------------------------"<<endl;
while(fgets(content[i],sizeof(content), file)!=NULL)
{
   cout<<content[i]<<endl;
   content[i][strlen(content[i])-1]='';
   i++;
   count++;
}
fclose(file);
cout<<"----------------------------"<<endl;
for(int k=0;k<count;k++)
{
   token1=strtok(content[k],"/");
   while (token1 != NULL)
    {
   if(key!=0)
   {
       if(flag==0)
       {
           store(token1);
       }
       else
       {
           item=atoi(token1);
           store2(item);
       }
       cout<<token1<<endl;
}
   token1 = strtok(NULL, "/");
   key++;
   }
   key=0;
   flag=1;
}
cout<<"The array is:"<<endl;
for(int i=0;i<p;i++)
{
   cout<<grade_array[i]<<" ";
}
cout<<" --------------"<<endl;
for(int j=0;j<q;j++)
{
   cout<<score_array[j]<<" ";
}
for(int k=0;k<q;k++)
{
   sum=sum+score_array[k];
}
avg=sum/q;
ofstream file2;
file2.open("clstatuc.txt",ios::out);
file2<<"Sl_NO"<<std::setw(12) <<"Grage Name"<<std::setw(12) <<" Average_Score" <<std::setw(12) <<"Grades"<<endl;
cout<<"------------------------------"<<endl;
cout<<"Student Name"<<" "<<"Sum value "<<" "<<"Average_Score"<<endl;
for(int i=0;i<10;i++)
{
   cout<<last_name[i]<<" "<<avg_array[i]<<" "<<grade[i]<<endl;
   file2<<i<<std::setw(12) <<last_name[i]<<std::setw(12) <<avg_array[i]<<std::setw(12) <<grade[i]<<" ";
}
}
void store(string token)
{
   grade_array[p]=token;
   p++;
}
void store2(int item)
{
   score_array[q]=item;
   q++;
}