so basically im collecting the user's input and depending on their choice, the output will be averaged or simply displayed.
I have tried running my code and its successful. can someone help me out please?
here is what i have so far.
if there is anything i should change please let me know, thank you.
/*
* File: main.cpp
* Author: gears
*
* Created on September 9, 2014, 12:28 AM
*/
#include <cstdlib>
#include <iostream>
usingnamespace std;
double getScores(double testScores[SIZE]);
void showMenu();
char getChoice(char choice);
double disoplayResult(char choice, double testScores[SIZE]);
constint SIZE =5;
/*
*
*/
int main(int argc, char** argv) {
double testScores[SIZE];
char choice;
getScores (testScores);
return 0;
}
double getScores(double testScores[SIZE])
{
cout << "what are the 5 test scores? "<< endl;
for ( int i; i < SIZE; i++)
{
cin >> testScores[i];
}
system ("cls");
}
void showMenu()
{
system ("cls");
cout << " A.) Calculate the average of the test scores. "<< endl;
cout << " B.) Display all test scores. "<< endl;
}
char getChoice(char choice)
{
char letter;
system ("cls");
cout << " Please enter a choice ";
cin >> letter;
return letter;
}
double disoplayResult(char choice, double testScores[SIZE])
{
system ("cls");
float sum = 0;
float average =0;
if (toupper(choice)== 'a')
{
for ( int i=0; i <=SIZE; i++)
{
sum += testScores[i];
}
average=sum/(SIZE+1);
cout << "the average is "<< average << endl;
}
elseif (toupper(choice)== 'b')
{
cout << "These are your TestScores "<< endl;
for ( int i = 0; i < SIZE; i++)
{
cout << testScores[i]<< endl;
}
}
}