Calculate each student average and grade for the class

Assignment Help Basic Computer Science
Reference no: EM13308442

Modify the Test Scores program from the code below Section into a class grade book that includes a class of up to 20 students and 3 test grades. Each test is read in as a separate file, so 3 Test files are required.

The students' grades should be kept in an array.

Once all three test scores are read in, calculate each student's average and grade for the class.

Also print a report of the each student's test grades, average and final grade as a table, and then print the averages of each Test and overall Test Average, as well as highest Test Grade of all Tests and the student with the highest class grade.

 

#include <iostream>

#include <iomanip>

#include<fstream>

 

using namespace std;

void readData(ifstream& inputFile, int list[], int size);

void holdscrn( );    

void print(int list[], int size);

int main()

{

    int scores[8] = {0};

    ifstream infile;

    infile.open("Test.txt");

    if (!infile) // need to add ! for not successful open

    {

        cout << "Cannot open the input file. Program terminates!"

             << endl;

        holdscrn( );   // Hold screen before exit    

        return 1;

    }

    readData(infile, scores, 8);

    print(scores, 8);

  cout << endl;

    infile.close();

    holdscrn( );   // Hold screen before exit

    return 0;

}

void readData(ifstream& inputFile, int list[], int size)

{

    int score;

    int index;

    inputFile >> score;

    while (inputFile)

    {

        index = score / 25;

        if (index == size)

            index--;

        if (index < size)

                list[index]++;

        inputFile >> score;

    }

    return;

}

void print(int list[], int size)

{

    int range;

    int lowRange = 0;

    int upperRange = 24;

    cout << "   Range # of Students" << endl;

    for (range = 0; range < size; range++)

    {

        cout << setw(3) << lowRange << " - "

             << upperRange << setw(15)

             << list[range] << endl;

        lowRange = upperRange + 1;

        upperRange = upperRange + 25;

        if (range == size - 2)

            upperRange++;

    }

    cout << endl;

    return;

}

void holdscrn( )   // void function to hold screen open before exit

{

    char holdscreen;

    cout << "\n\n\tEnter one character and press return to exit program: ";

    cin >> holdscreen;

    return;

}

 

Reference no: EM13308442

Give a polynomial-time algorithm to solve 2-sat

The 2-SAT problem is, given a Boolean formula in 2-conjunctive normal form (CNF), to decide whether the formula is satisfiable. 2-SAT is like 3-SAT, except that each clause

Formulate this as an optimization problem

Our aim is to use the available fencing material and cover the maximum area of the field. Formulate this as an optimization problem by writing down the objective function an

Earmarks in legislation or pharmaceutical salespersons

In 100 word, discuss bribery. Would actions, such as politicians adding earmarks in legislation or pharmaceutical salespersons giving away drugs to physicians, constitute br

Find the price of a call option struck at zero

There are no interest rates. An asset is worth zero today and goes up or down by 1 each day. Find the price of a call option struck at zero as a function of the number of st

Identify methods of securing routers and switches

Write a 1-page summary that discusses the following about creating secure networks: -identify methods of securing routers and switches -recognize characteristics of a variet

Transform a sequential circuit for a randomaccess memory

Design the additional circuitry needed to transform a sequential circuit for a randomaccess memory into one for a tape memory. Give upper bounds on the size and depth of the

List two latest full disk encryption methods

List two latest full disk encryption methods with appropriate examples. Explain different benefits of full disk encryption or known shortcoming with the technology. Explain th

Different document processing applications in more detail

First, make a list of as many different word document applications as you can find. •Second, research at least two different document processing applications in more detail. Y

Reviews

Write a Review

 
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd