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

Questions Cloud

Estimate the wet density-dry density and buoyant density : A sample of natural glacial till was taken from below the groundwater table. The water content was found to be 52%. Estimate the wet density, dry density, buoyant density, porosity, and void ratio.
Build a sorted double-linked list such : For example, you build a list of characters, then you can print it out as: "a b c d e" or "e d c b a". The input is of an random character list is from the keyboard.
What is the water content of the material when saturated : The dry density of a compacted sand is 1.87 Mg/m^3 and the density of the solids is 2.67 Mg/m^3. What is the water content of the material when saturated. Include a phase diagram.
Effects on inflation and real gdp that these policies will : Assume the economy initially is in a long run equilibrium plus the following:  the U.S. dollar is relatively strong against all major foreign currencies.  Suppose the Congress and the President decide to decrease government spending dramatically
Calculate each student 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.
Find the water content-void ratio and porosity : When it is dried out in an oven, it weighs 122.7 g. The specific gravity of solids is found to be 2.66. Find the water content, void ratio, porosity, degree of saturation, and wet and dry unit weights.
What force does the other person lift : Two people are carrying a uniform wooden board that is 3.40m long and weighs 145N. What force does the other person lift
How i should write out the source file : Given struct vector scale_vector (struct vector v, double scalar) for the header file.
Discuss some useful applications for n-dimensional arrays : Discuss some useful applications for n-dimensional arrays, such as graphical 3-D or biotechnology applications.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Feature set of free helix forensics cd

Visit Helix web site and read about feature set of free Helix forensics CD. Note that documentation for Helix is not on CD, to keep it down to ~700MB.

  Create a meaningful shape in the middle band

Specifically, a user can perform the following four operations to create a meaningful shape in the middle band.

  Write a usable code snippet that demonstrates an iterator

A client of K & R has come to you for information regarding loops, iterators, and arrays. He needs you to help him comprehend these concepts. To assist this client, briefly address the following in a 1-2 page Notepad document.

  What would be the best choice of the degree

A B+ - tree index is to be built on the name attribute of the relation student. Assume that all the student names are o length 8bytes, disk blocks are of size 512 bytes , and index pointer are of size 4bytes. Given this scenariom, what would be th..

  Input and output of entire objects to or from a file

Which of the following classes enable input and output of entire objects to or from a file?   SerializedInputStream and SerializedOutputStream

  Write a program using c language that converts gps cordinate

I want to write a simple program using C language that converts GPS coordinates between three different notational forms

  Deployment and ongoing operation after implementations

Your plan requires two sections, one for deployment and another for ongoing operation after implementation. The vendor offers a contracting service for installation at $140 per hour.

  Write a declaration for an enumerated data type

A pet store sells dogs, cats, birds, and hamsters. Write a declaration for an enumerated data type that can represent the types of pets the store sells.

  What is the average length of the search for worst-fit

another placement algorithm for dynamic partitioning is referred to as worst-fit. In this case, the largest free block of memory is used for bringing in process. Discuss the pros and cons of this method compared to first-, next-, and best fit. Wha..

  Write a program that accepts a temperature

Write a program that accepts a temperature in Fahrenheit from a user and converts it to Celsius by subtracting 32 from the Fahrenheit value and multiplying the result by 5/9. Display both values. Save the class as FahrenheitToCelsius.java.

  Using one- and two-dimensional arrays with functions.

Objective using one- and two-dimensional arrays with functions.

  Explaining mismatched file headers to extensions

What procedures would you require to follow to retrieve evidence? Identify mismatched file headers to extensions.

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