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

Write a Java program to calculate students average test scores and their grades.

ID: 3761061 • Letter: W

Question

Write a Java program to calculate students average test scores and their grades. You may assume the following data: dimensional array to store the test score, and a parallel one-dimensional array to store grades. Your program must contain at least the following methods: a method to read and store data into two arrays, a method to calculate the average test score and grade and a method to output the results. Have your program also output the class average. Grade calculation to be computed as follows:

Explanation / Answer

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;

/* Function Declarations */
char calculate_Grade(double);
void calcAverage(ifstream &, int [], int, double &);
void calclasseAverage(ifstream &, int [],double &,double &);
intSum = 0;

int main(void)

{
    string name;
    int i,numgrades=5,grade[5];
    double average;
   double classAvg = 0;
   intSum=0;
   double classAvg2 = 0;
   int numStudents=0;
        char letter;
        ifstream inputfile;
   inputfile.open("text1.txt");

    if(inputfile.fail())
    {
        cout<<"input file did not open please check it ";
        return 1;
    }


    inputfile>>name;                
    while(inputfile)     
    {
        calcAverage(inputfile,grade,numgrades,average);
        letter = calculate_Grade(average);
        numStudents++;
        cout<<name<<" ";
      
    for(i=0;i<numgrades;i++)
    {
     cout<<grade[i]<<" ";
   
    Sum=(SumCount+grade[i]);  

    }
         classAvg2=classAvg2+average;
         cout<<average<<" "<<letter<<" ";
         inputfile>>name;
   |
     cout << endl << " # students: " << numStudents << " Class Average: " << classAvg2/numStudents << endl;

    inputfile.close();

    return 0;
}


/* Function to retrieve the letter grade. */

char calculate_Grade(double average)
{
    if(average >=90)
        return 'A';
    else if(average >=80)
        return 'B';
    else if(average >=70)
        return 'C';
    else if(average>=60)
        return 'D';
    else
        return 'F';
}

/* Function to read an entry and calculate the average. */

void calcAverage(ifstream &in, int grade[], int max, double &average) //
{
    int i=0,sum=0;
    for(i=0; i < max ;i++)
    {
        in>>grade[i];
        sum+=grade[i];
    }
    average=(double)sum/max;
}

Function to calculat the class average.
void calclasseAverage(ifstream &in, int grade[], double &average,double &classAvg)
{
   classAvg = 0;
    for(int i = 7 ;i < 8;i++)
   {for(int j = 1; j < 22 ;j++)
    {
        in>>average;
        classAvg = classAvg + average;
   }
    }
  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote