1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
// ****************************************************************************
// Program: Gradebook Application
// Author:
// Date: 04/27/2012
// Purpose: the purpose of the program is use an array of strings objects the
// hold five students names, an array of five characters to hold the five
// students letter grades and five arrays of four doubles so each students set
// of test scores. The program should allow the user to enter each student's
// name and his or her for test scores. The program will calculate and display
// each student average and a leeter grade based on the average.
// *****************************************************************************
# include <iostream>
# include <iomanip>
using namepace std;
// Function prototypes
void getTestScores(double[],int);
void getStudentName(string[]);
double getTotal(const double [], int);
double getLowest(const double[],int);
int main{}
{
const int SIZE = 5; // Array size
string studentName[SIZE]; // Array of student names
double testScores[SIZE]; // Array of test scores
total, // Total of the scores
lowestScore, // Lowest test score
average; // Average test score
// setup numeric output formatting.
cout << fixed << showpoint << setprecision(1);
//Get the student name from the user.
getStudentName(studentName,SIZE);
//Get the test scores from the user.
getTestScores(testScores,SIZE);
//Get the lowest test score.
lowestScore = getLowest(testScores,SIZE);
// Subtract the lowest score from the total.
total =lowestScore;
//Calculate the average.
average = total / (SIZE - 1)
// Display the average.
cout << "The average with the lowest score " << "dropped is " << average
<< ".\n";
return 0;
}
// *****************************************************************************
// The getTestScores function accepts an array and size has arguments.
// It promptly uses energy test scores, which are stored in the array.
// *****************************************************************************
void getTestScores(double scores[], int size)
{
// Loop counter
int index;
// Get each test score.
for(index=0,index<=size-1;index++)
{
cout << "Enter the test score number " << (index+1) << ": ";
cin >> scores[index];
}
}
// *****************************************************************************
// The getTotal function accepts a double rate and its size has arguments.
// The sum of the array's elements is returned have a double.
// *****************************************************************************
double getTotal(const double array[],int size)
{
double total = 0; // Accumlator
// Add each element to total.
for(int count =0; count < size, count ++)
total += array[count];
// Return the total.
return total;
}
// *****************************************************************************
// The getLowest but this is a double rate and exercises arguments.
// The lowest value in the array is returned as a double.
// *****************************************************************************
double get Lowest(const double array[],int size)
{
double lowest; // to hold the lowest value
// Get the first array's element.
lowest = array[0];
//Step through the rest of the arry. when a value less then the lowest
// is found, assign it to lowest
for(int count = 1; count < size, count ++)
{
if(array[count]<lowest)
lowest = array[count];
}
// Return the lowest value.
return lowest;
}
|