< previous page page_171 next page >

Page 171
Module Structure Chart:
0171-01.gif
Variables
NameData TypeDescription
test1intScore for first test
test2intScore for second test
test3intScore for third test
weight1floatWeight for first test
weight2floatWeight for second test
weight3floatWeight for third test
avefloatWeighted average of the tests
scoreFileifstreamInput data file

Here is the complete program. There are no prompting messages because the input is taken from a file.
//**************************************************************
// TestAverage program
// This program finds the weighted average of three test scores
//**************************************************************
#include <iostream.h>
#include <fstream.h>    // For file I/O
#include <iomanip.h>    // For setw() and setprecision()

int main()
{
    int      test1;               // Score for first test
    int      test2;               // Score for second test
    int      test3;               // Score for third test
    float    weight1;             // Weight for first test
    float    weight2;             // Weight for second test
    float    weight3;             // Weight for third test
    float    ave;                 // Weighted average of the tests
    ifstream scoreFile;           // Input data file

 
< previous page page_171 next page >