|
|
|
| Variables | | | | Name | Data Type | Description | | test1 | int | Score for first test | | test2 | int | Score for second test | | test3 | int | Score for third test | | weight1 | float | Weight for first test | | weight2 | float | Weight for second test | | weight3 | float | Weight for third test | | ave | float | Weighted average of the tests | | scoreFile | ifstream | Input 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
|
|
|
|
|
|