course.wilkes.edu/CS125Labs
Welcome to the site for CS 125 labs!

 

grades.cpp

Prev | Next | Lab 9

// grades.cpp computes letter grades using the "curve" method.
//
// Begun by: Adams, Fall 1995, CPSC151 at Calvin College.
// Completed by:
//
// Input(kbd): the name of an input file containing lines of the form:
//                 name score
// Input(file): a sequence of names and scores.
// Output: the sequence of names with corresponding letter grades,
//          based on the "curve" method of grading.
//*******************************************************************
             
#include <iostream>             // cin, cout, ...
#include <fstream>              // ifstream, ofstream, ...
#include <cassert>              // assert()
#include <string>               // string
#include <vector>               // vector
#include <cstdlib>              // exit
using namespace std;

#include "DoubleVectorOps.h" // Average(), StandardDev(), ...

// prototype FillVectors, ComputeLetterGrades and DisplayVectors here

int main() { // define nameVec as a vector of string objects // define scoreVec as a vector of double objects // define infile as an ifstream

cout << "Enter the name of the scores file: "; string inFileName; cin >> inFileName;

// open file infile with inFileName // check to see that the open worked; error message if not

// FillVectors(infile, nameVec, scoreVec);

cout << endl << "Mean score: " // << Average(scoreVec) << endl << "Std. Dev: " // << StandardDev(scoreVec) << endl;

// define gradeVec as a vector of character objects

// gradeVec = ComputeLetterGrades(scoreVec);

// DisplayVectors(cout, nameVec, scoreVec, gradeVec); }

//*********************************************************** // FillVectors fills nameVect and scoreVec from a file. * // * // Receive: infile, an opened ifstream reference, * // nameVec, a vector of strings, * // scoreVec, a vector of doubles. * // Input: a sequence of names and scores, from infile . * // Passback: the sequence of names in nameVec, * // the sequence of scores in scoreVec. * //***********************************************************

// define FillVectors() here

//***************************************************** // Compute letter grades, using "curve" grading. * // Receive: scores, a list of scores. * // Return: a list of the corresponding letter grades. * //*****************************************************

// define ComputeLetterGrades() here

//****************************************************** // DisplayVectors displays the various vectors. * // * // Receive: out, an ostream, * // names, a vector of strings, * // scores, a vector of doubles, and * // grades, a vector of chars. * // Output: a sequence of names, scores and grades. * //******************************************************

// define DisplayVectors() here

Prev | Next | Lab 9

 
  Home

Help

Lab 0

Lab 1

Lab 2

Lab 3a

Lab 3b

Lab 4

Lab 5

Lab 6

Lab 7

Lab 8

Lab 9

Lab 10

Lab 11

Lab 12

Lab 13



Membership

Login




Last update: Tuesday, November 13, 2001 at 1:19:06 PM.
visitors to this page.