//Maxwell Brewer CS1A Chapter 3, P. 143, #3
//
/***************************************************************
*
* AVERAGE TEST SCORES
* _____________________________________________________________
*
* This program will receive input from the user
* and output a calculation of average test scores.
* The user will input each test score and the
* program will output the average score..
* _____________________________________________
* INPUT
*
* Test scores 1-5
*
* OUTPUT
*
* Average test scores
*
***************************************************************/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main( ) {
// Initialization
const char msgTest1[ 40 ] = "Enter the score from test 1: \n " ;
const char msgTest2[ 40 ] = "Enter the score from test 2: \n " ;
const char msgTest3[ 40 ] = "Enter the score from test 3: \n " ;
const char msgTest4[ 40 ] = "Enter the score from test 4: \n " ;
const char msgTest5[ 40 ] = "Enter the score from test 5: \n " ;
const char msgEnd [ 50 ] = "The average of the scores in the test is: " ;
double test1, test2, test3, test4, test5;
float sum;
double average;
// Display input prompts
cout << msgTest1;
cin >> test1;
cout << msgTest2;
cin >> test2;
cout << msgTest3;
cin >> test3;
cout << msgTest4;
cin >> test4;
cout << msgTest5;
cin >> test5;
sum = test1 + test2 + test3 + test4 + test5;
average = sum / 5 ;
// Output
cout << msgEnd << fixed << setprecision( 1 ) << average;
return 0 ;
}
Ly9NYXh3ZWxsIEJyZXdlciAgICAgICAgICAgIENTMUEgICAgICAgICAgIENoYXB0ZXIgMywgUC4gMTQzLCAjMwovLwovKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqCiAqIAogKiBBVkVSQUdFIFRFU1QgU0NPUkVTCiAqIF9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KICogCiAqIFRoaXMgcHJvZ3JhbSB3aWxsIHJlY2VpdmUgaW5wdXQgZnJvbSB0aGUgdXNlcgogKiBhbmQgb3V0cHV0IGEgY2FsY3VsYXRpb24gb2YgYXZlcmFnZSB0ZXN0IHNjb3Jlcy4KICogVGhlIHVzZXIgd2lsbCBpbnB1dCBlYWNo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